ALICE 1.3  1.3.14
Developer documentation
alice-desktop-1.3-linux-test.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 #
4 # ADALM1000 alice-desktop 1.3.py(w) (1-28-2022)
5 # For Python version 2.7 or 3.7, Windows OS and Linux OS
6 # With external module pysmu ( libsmu >= 1.0.2 for ADALM1000 )
7 # optional split I/O modes for Rev F hardware supported
8 # Uses new firmware (2.17 or >) that support control of ADC mux configure
9 # Created by D Mercer ()
10 #
11 #
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 #
21 # If runing from source you can un-comment the following to include pyplot
22 try:
23  from matplotlib import pyplot as plt
24  matplot_found = True
25 except:
26  matplot_found = False
27 #
28 import csv
29 import wave
30 import os
31 #import requests
32 import sys
33 import struct
34 import subprocess
35 from time import gmtime, strftime
36 # Check to see if user passed init file name on command line
37 if len(sys.argv) > 1:
38  InitFileName = str(sys.argv[1])
39  print( 'Init file name: ' + InitFileName )
40 else:
41  InitFileName = 'alice_init.ini'
42 
43 if sys.version_info[0] == 2:
44  print ("Python 2.x")
45  import urllib2
46  import tkFont
47  from Tkinter import *
48  from ttk import *
49  from tkFileDialog import askopenfilename
50  from tkFileDialog import asksaveasfilename
51  from tkSimpleDialog import askstring
52  from tkMessageBox import *
53 if sys.version_info[0] == 3:
54  print ("Python 3.x")
55  import urllib.request, urllib.error, urllib.parse
56  from tkinter.font import *
57  from tkinter import *
58  from tkinter.ttk import *
59  from tkinter.filedialog import askopenfilename
60  from tkinter.filedialog import asksaveasfilename
61  from tkinter.simpledialog import askstring
62  from tkinter.messagebox import *
63 #
64 import webbrowser
65 try:
66  from pysmu import *
67  pysmu_found = True
68 except:
69  pysmu_found = False
70 #
71 # check which operating system
72 import platform
73 #
74 RevDate = "28 Jan 2022"
75 SWRev = "1.3 "
76 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.12/alice-desktop-1.3-setup.exe'
77 # small bit map of ADI logo for window icon
78 TBicon = """
79 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
80 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
81 i8fUAgA7
82 """
83 
84 root=Tk()
85 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
86 img = PhotoImage(data=TBicon)
87 root.call('wm', 'iconphoto', root._w, '-default', img)
88 print("Windowing System is " + str(root.tk.call('tk', 'windowingsystem')))
89 
90 GRW = 720 # Width of the time grid 720 default
91 GRH = 390 # Height of the time grid 390 default
92 X0L = 55 # Left top X value of time grid
93 Y0T = 25 # Left top Y value of time grid
94 #
95 GRWF = 720 # Width of the spectrum grid 720 default
96 GRHF = 390 # Height of the spectrum grid 390 default
97 X0LF = 45 # Left top X value of spectrum grid
98 Y0TF = 25 # Left top Y value of spectrum grid
99 #
100 GRWBP = 720 # Width of the Bode Plot grid 720 default
101 GRHBP = 390 # Height of the Bode Plot grid 390 default
102 X0LBP = 45 # Left top X value of Bode Plot grid
103 Y0TBP = 25 # Left top Y value of Bode Plot grid
104 #
105 GRWXY = 420 # Width of the XY grid 420 default
106 GRHXY = 390 # Height of the XY grid 390 default
107 X0LXY = 55 # Left top X value of XY grid
108 Y0TXY = 25 # Left top Y value of XY grid
109 #
110 GRWIA = 400 # Width of the grid 400 default
111 GRHIA = 400 # Height of the grid 400 default
112 X0LIA = 37 # Left top X value of grid
113 Y0TIA = 25 # Left top Y value of grid
114 #
115 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
116 GRHNqP = 400 # Height of the grid 400 default
117 X0LNqP = 25 # Left top X value of grid
118 Y0TNqP = 25 # Left top Y value of grid
119 #
120 GRWNiC = 400 # Width of the Nichols plot grid 400 default
121 GRHNiC = 400 # Height of the grid 400 default
122 X0LNiC = 25 # Left top X value of grid
123 Y0TNiC = 25 # Left top Y value of grid
124 #
125 GRWPhA = 400 # Width of the grid 400 default
126 GRHPhA = 400 # Height of the grid 400 default
127 X0LPhA = 37 # Left top X value of grid
128 Y0TPhA = 25 # Left top Y value of grid
129 #
130 FontSize = 8
131 BorderSize = 1
132 MouseX = MouseY = -10
133 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
134 
135 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
136 COLORcanvas = "#000000" # 100% black
137 COLORgrid = "#808080" # 50% Gray
138 COLORzeroline = "#0000ff" # 100% blue
139 COLORtrace1 = "#00ff00" # 100% green
140 COLORtrace2 = "#ff8000" # 100% orange
141 COLORtrace3 = "#00ffff" # 100% cyan
142 COLORtrace4 = "#ffff00" # 100% yellow
143 COLORtrace5 = "#ff00ff" # 100% magenta
144 COLORtrace6 = "#C80000" # 90% red
145 COLORtrace7 = "#8080ff" # 100% purple
146 COLORtraceR1 = "#008000" # 50% green
147 COLORtraceR2 = "#905000" # 50% orange
148 COLORtraceR3 = "#008080" # 50% cyan
149 COLORtraceR4 = "#808000" # 50% yellow
150 COLORtraceR5 = "#800080" # 50% magenta
151 COLORtraceR6 = "#800000" # 80% red
152 COLORtraceR7 = "#4040a0" # 80% purple
153 COLORtext = "#ffffff" # 100% white
154 COLORtrigger = "#ff0000" # 100% red
155 COLORsignalband = "#ff0000" # 100% red
156 ButtonGreen = "#00ff00" # 100% green
157 ButtonRed = "#ff0000" # 100% red
158 GUITheme = "Light"
159 ButtonOrder = 0
160 SBoxarrow = 11
161 Closed = 0
162 ColorMode = IntVar(0)
163 # # Can be Light or Dark or Blue or LtBlue or Custom where:
164 FrameBG = "#d7d7d7" # Background color for frame
165 ButtonText = "#000000" # Button Text color
166 # Widget relief can be RAISED, GROOVE, RIDGE, and FLAT
167 ButRelief = RAISED
168 LabRelief = FLAT
169 FrameRefief = RIDGE
170 LocalLanguage = "English"
171 
172 OnBoardRes = 50.83
173 AD584act = 2.5
174 # Set sample buffer size
175 HoldOff = 0.0
176 LShift = 0
177 BaseSampleRate = 100000
178 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
179 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
180 MinSamples = 2000
181 MaxSamples = 200000
182 ETSrecord = 2000
183 AWGRecLength = 32768
184 DISsamples = GRW
185 First_Slow_sweep = 0
186 Slow_Sweep_Limit = 200
187 # set initial trigger conditions
188 TRIGGERlevel = 2.5 # Triggerlevel in volts
189 
190 MathString = "VBuffA[t] + VBuffB[t]"
191 MathUnits = " V"
192 MathXString = "VBuffA[t]"
193 MathXUnits = " V"
194 MathYString = "VBuffB[t]"
195 MathYUnits = " V"
196 UserAString = "MaxV1-VATop"
197 UserALabel = "OverShoot"
198 UserBString = "MinV2-VBBase"
199 UserBLabel = "UnderShoot"
200 MathAxis = "V-A"
201 MathXAxis = "V-A"
202 MathYAxis = "V-B"
203 AWGAMathString = "(VBuffA + VBuffB)/2"
204 AWGBMathString = "(VBuffA + VBuffB)/2"
205 AWGAcsvFile = "examplea.csv"
206 AWGBcsvFile = "exampleb.csv"
207 AWGAwavFile = "examplea.wav"
208 AWGBwavFile = "exampleb.wav"
209 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
210 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
211 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
212 AWGFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
213 AWGFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
214 ChaMeasString1 = "DCV1"
215 ChaMeasString2 = "DCI1"
216 ChaMeasString3 = "SV1"
217 ChaMeasString4 = "MaxV1-MinV1"
218 ChaMeasString5 = "MaxI1-MinI1"
219 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
220 ChbMeasString1 = "DCV2"
221 ChbMeasString2 = "DCI2"
222 ChbMeasString3 = "SV2"
223 ChbMeasString4 = "MaxV2-MinV2"
224 ChbMeasString5 = "MaxI2-MinI2"
225 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
226 ChaLableSrring1 = "CHA-DCV "
227 ChaLableSrring2 = "CHA-DCI "
228 ChaLableSrring3 = "CHA-TRMS "
229 ChaLableSrring4 = "CHA-VP-P "
230 ChaLableSrring5 = "CHA-IP-P "
231 ChaLableSrring6 = "CHA-ACRMS "
232 ChbLableSrring1 = "CHB-DCV "
233 ChbLableSrring2 = "CHB-DCI "
234 ChbLableSrring3 = "CHB-TRMS "
235 ChbLableSrring4 = "CHB-VP-P "
236 ChbLableSrring5 = "CHB-IP-P "
237 ChbLableSrring6 = "CHB-ACRMS "
238 LabelPlotText = IntVar(0)
239 PlotLabelText = "Custom Plot Label"
240 
241 GridWidth = IntVar(0)
242 GridWidth.set(1)
243 TRACEwidth = IntVar(0)
244 TRACEwidth.set(1)
245 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
246 TRACEaverage.set(8)
247 Vdiv = IntVar(0)
248 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
249 LPFTrigger = IntVar(0) # trigger lpf on/off
250 Trigger_LPF_length = IntVar(0)
251 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
252 HarmonicMarkers = IntVar(0)
253 HarmonicMarkers.set(3)
254 AWGShowAdvanced = IntVar(0)
255 AWGShowAdvanced.set(0)
256 AWG_Amp_Mode = IntVar(0)
257 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
258 AWGA_Ext_Gain = DoubleVar(0)
259 AWGA_Ext_Gain.set(1.0)
260 AWGA_Ext_Offset = DoubleVar(0)
261 AWGA_Ext_Offset.set(0.0)
262 AWGB_Ext_Gain = DoubleVar(0)
263 AWGB_Ext_Gain.set(1.0)
264 AWGB_Ext_Offset = DoubleVar(0)
265 AWGB_Ext_Offset.set(0.0)
266 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
267 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
268 Two_X_Sample.set(0)
269 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
270 ADC_Mux_Mode.set(0)
271 Last_ADC_Mux_Mode = 0
272 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
273 Alternate_Sweep_Mode.set(0)
274 #
275 ChopModeFilter = [0.25, 0.25, 0.25, 0.25] # [0.25, 0.25, 0.25, 0.25]
276 # ChopModeFilter = [0, 1, 2, 3, 4, 3, 2, 1, 0]
277 # ChopModeFilter = numpy.array(ChopModeFilter) / 16
278 Roll_Mode = IntVar(0) # select roll sweep (slow) mode
279 Roll_Mode.set(0)
280 #
281 UnAvgSav = IntVar(0) # Flag to save un trace averaged buffers
282 UnAvgSav.set(0)
283 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
284 ZEROstuffing.set(1)
285 FFTwindow = IntVar(0) # FFT window function variable
286 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
287  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
288 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
289 RelPhaseCenter = IntVar(0)
290 RelPhaseCenter.set(0) # Center line value for phase plots
291 ImpedanceCenter = IntVar(0)
292 ImpedanceCenter.set(0) # Center line value for impedance plots
293 MultipleBoards = IntVar(0)
294 MultipleBoards.set(0) # Turn on access for multiple m1k boards
295 IgnoreFirmwareCheck = 0
296 EnableScopeOnly = 0
297 EnableXYPlotter = 1
298 EnablePhaseAnalizer = 1
299 EnableSpectrumAnalizer = 1
300 EnableBodePlotter = 1
301 EnableImpedanceAnalizer = 1
302 EnableOhmMeter = 1
303 EnableDigIO = 1
304 EnableCommandInterface = 0
305 EnableMuxMode = 0
306 EnablePIODACMode = 0
307 EnableMinigenMode = 0
308 EnablePmodDA1Mode = 0
309 EnableDigPotMode = 0
310 EnableGenericSerialMode = 0
311 EnableAD5626SerialMode = 0
312 EnableDigitalFilter = 0
313 EnableMeasureScreen = 0
314 EnableETSScreen = 0
315 EnableHSsampling = 0
316 EnableUserEntries = 0
317 AllowFlashFirmware = 0
318 DeBugMode = 0
319 ShowTraceControls = 0
320 # ADC Mux defaults
321 v1_adc_conf = 0x20F1
322 i1_adc_conf = 0x20F7
323 v2_adc_conf = 0x20F7
324 i2_adc_conf = 0x20F1
325 #
326 MouseFocus = 1
327 HistAsPercent = 0
328 ShowBallonHelp = 0
329 contloop = 0
330 discontloop = 0
331 AwgLayout = "Horz"
332 MarkerLoc = 'UL' # can be UL, UR, LL or LR
333 CHA_TC1 = DoubleVar(0)
334 CHA_TC1.set(1)
335 CHA_TC2 = DoubleVar(0)
336 CHA_TC2.set(1)
337 CHB_TC1 = DoubleVar(0)
338 CHB_TC1.set(1)
339 CHB_TC2 = DoubleVar(0)
340 CHB_TC2.set(1)
341 CHA_A1 = DoubleVar(0)
342 CHA_A1.set(1)
343 CHA_A2 = DoubleVar(0)
344 CHA_A2.set(1)
345 CHB_A1 = DoubleVar(0)
346 CHB_A1.set(1)
347 CHB_A2 = DoubleVar(0)
348 CHB_A2.set(1)
349 Auto_ETS_Comp = IntVar(0)
350 ETS_TC1 = DoubleVar(0)
351 ETS_TC1.set(0.18333)
352 ETS_A1 = DoubleVar(0)
353 ETS_A1.set(5.0)
354 ETS_TC2 = DoubleVar(0)
355 ETS_TC2.set(0.03)
356 ETS_A2 = DoubleVar(0)
357 ETS_A2.set(5.0)
358 PhaseOffset1x = 37
359 PhaseOffset2x = 37
360 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
361 # 'aqua' built-in native Mac OS X only; Native Mac OS X
362 windowingsystem = root.tk.call('tk', 'windowingsystem')
363 ScreenWidth = root.winfo_screenwidth()
364 ScreenHeight = root.winfo_screenheight()
365 # print(str(ScreenWidth) + "X" + str(ScreenHeight))
366 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
367  Style_String = 'aqua'
368  # On Macs, allow the dock icon to deiconify.
369  root.createcommand('::tk::mac::ReopenApplication', root.deiconify)
370  root.createcommand('::tk::mac::Quit', root.destroy)# Bcloseexit)
371  # On Macs, set up menu bar to be minimal.
372  root.option_add('*tearOff', False)
373  if sys.version_info[0] == 2:
374  menubar = tKinter.Menu(root)
375  appmenu = tKinter.Menu(menubar, name='apple')
376  else:
377  menubar = tkinter.Menu(root)
378  appmenu = tkinter.Menu(menubar, name='apple')
379  # menubar = tk.Menu(root)
380  # appmenu = tk.Menu(menubar, name='apple')
381  menubar.add_cascade(menu=appmenu)
382  # appmenu.add_command(label='Exit', command=Bcloseexit)
383  root['menu'] = menubar
384 else:
385  Style_String = 'alt'
386 # Check if there is an alice_init.ini file to read in
387 try:
388  import alice
389  import pathlib
390 # pathlib only available as standard in Python 3.4 and higher. For Python 2.7 must manually install package
391  path = pathlib.Path(alice.__file__).parent.absolute()
392  filename = os.path.join(path, "resources", InitFileName) # "alice_init.ini")
393  InitFile = open(filename)
394  for line in InitFile:
395  try:
396  exec( line.rstrip(), globals(), globals())
397  #exec( line.rstrip() )
398  except:
399  print("Skiping " + line.rstrip())
400  InitFile.close()
401 except:
402  try:
403  InitFile = open(InitFileName) # "alice_init.ini"
404  for line in InitFile:
405  try:
406  exec( line.rstrip(), globals(), globals())
407  #exec( line.rstrip() )
408  except:
409  print("Skiping " + line.rstrip())
410  InitFile.close()
411  except:
412  print( "No Init File Read. " + InitFileName + " Not Found")
413 #
414 XOLXY = X0L = FontSize * 7
415 XOLF = XOLBP = XOLIA = int(FontSize * 4.625)
416 XOLNqP = XOLNiC = int(FontSize * 3.125)
417 root.style = Style()
418 try:
419  root.style.theme_use(Style_String)
420 except:
421  root.style.theme_use('default')
422 if MouseFocus == 1:
423  root.tk_focusFollowsMouse()
424 #
425 DevID = "m1k"
426 #
427 if sys.version_info[0] == 2:
428  default_font = tkFont.nametofont("TkDefaultFont")
429 if sys.version_info[0] == 3:
430  default_font = tkinter.font.nametofont("TkDefaultFont")
431 default_font.configure(size=FontSize)
432 
433 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
434 
435 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
436 
437 SAMagdiv = ("10nV", "100nV", "1uV", "10uV", "100uV", "1mV", "10mV", "0.1", "1.0", "10.0")
438 
439 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
440 ResScalediv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
441 SampRateList = (1024, 2048, 4096, 8194, 16393, 32787, 65574, 93023, 93385, 93750, 94118,
442  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
443 NoiseList =[ "None", "Uniform", "Gaussian"]
444 TIMEdiv = 0.5
445 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
446 
447 
448 AWGAAmplvalue = 0.0
449 AWGAOffsetvalue = 0.0
450 AWGAFreqvalue = 0.0
451 AWGAPhasevalue = 0
452 AWGAdelayvalue = 0
453 AWGADutyCyclevalue = 50
454 AWGAWave = 'dc'
455 AWGBAmplvalue = 0.0
456 AWGBOffsetvalue = 0.0
457 AWGBFreqvalue = 0.0
458 AWGBPhasevalue = 0
459 AWGBdelayvalue = 0
460 AWGBDutyCyclevalue = 50
461 AWGBWave = 'dc'
462 AWGACycles = 1
463 AWGBCycles = 1
464 AWGABurstDelay = 0
465 AWGBBurstDelay = 0
466 Reset_Freq = 300
467 MeasGateLeft = 0.0
468 MeasGateRight = 0.0 # in mSec
469 MeasGateNum = 0
470 MeasGateStatus = IntVar(0)
471 MeasGateStatus.set(0)
472 #
473 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
474 
475 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
476 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
477 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
478 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
479 PeakVA = PeakVB = PeakIA = PeakIB = 0.0
480 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
481 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
482 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = 0.0
483 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = 0.0
484 CHADCy = CHBDCy = 0
485 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
486 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
487 # Calibration coefficients
488 CHAVGain = CHBVGain = 1.0
489 CHAVOffset = CHBVOffset = 0.0
490 # Initialisation of general variables
491 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
492 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
493 # Other global variables required in various routines
494 CANVASwidth = GRW + 2 * X0L # The canvas width
495 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
496 
497 ADsignal1 = [] # Ain signal array channel A and B
498 VBuffA = []
499 VBuffB = []
500 IBuffA = []
501 IBuffB = []
502 VBuffMA = []
503 VBuffMB = []
504 VBuffMC = []
505 VBuffMD = []
506 VmemoryMuxA = []
507 VmemoryMuxB = []
508 VmemoryMuxC = []
509 VmemoryMuxD = []
510 #
511 VUnAvgA = []
512 VUnAvgB = []
513 IUnAvgA = []
514 IUnAvgB = []
515 #
516 DBuff0 = []
517 DBuff1 = []
518 DBuff2 = []
519 DBuff3 = []
520 #
521 VAresult = []
522 VBresult = []
523 IAresult = []
524 IBresult = []
525 PhaseIA = []
526 PhaseIB = []
527 PhaseVA = []
528 PhaseVB = []
529 DFiltACoef = [1]
530 DFiltBCoef = [1]
531 DigFiltA = IntVar(0)
532 DigFiltA.set(0)
533 DigFiltABoxCar = IntVar(0)
534 DigFiltBBoxCar = IntVar(0)
535 DigDeSkewA = IntVar(0)
536 DigDeSkewB = IntVar(0)
537 DigFiltB = IntVar(0)
538 DigFiltB.set(0)
539 DigBuffA = IntVar(0)
540 DigBuffB = IntVar(0)
541 DigBuffA.set(0)
542 DigBuffB.set(0)
543 AWGFiltA = IntVar(0)
544 AWGFiltB = IntVar(0)
545 AWGFiltABoxCar = IntVar(0)
546 AWGFiltBBoxCar = IntVar(0)
547 AWGFiltACoef = [1]
548 AWGFiltBCoef = [1]
549 VFilterA = {}
550 VFilterB = {}
551 SampleRateStatus = IntVar(0)
552 ETSStatus = IntVar(0)
553 ETSDisp = IntVar(0)
554 ETSDir = IntVar(0)
555 #
556 AWGAwaveform = []
557 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
558 AWGBwaveform = []
559 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
560 VmemoryA = numpy.ones(1) # The memory for averaging
561 VmemoryB = numpy.ones(1)
562 ImemoryA = numpy.ones(1) # The memory for averaging
563 ImemoryB = numpy.ones(1)
564 TRACEresetTime = True # True for first new trace, false for averageing
565 TRACEresetFreq = True # True for first new trace, false for averageing
566 AWGScreenStatus = IntVar(0)
567 
568 T1Vline = [] # Voltage Trace line channel A
569 T2Vline = [] # Voltage Trace line channel B
570 T1Iline = [] # Current Trace line channel A
571 T2Iline = [] # Current Trace line channel B
572 TMAVline = [] # Voltage Trace line MUX channel A
573 TMBVline = [] # Voltage Trace line MUX channel B
574 TMCVline = [] # Voltage Trace line MUX channel C
575 TMDVline = [] # Voltage Trace line MUX channel D
576 TMARline = [] # V reference Trace line MUX channel A
577 TMBRline = [] # V reference Trace line MUX channel B
578 TMCRline = [] # V reference line MUX channel C
579 TMDRline = [] # V reference line MUX channel D
580 XYlineVA = [] # XY Trace lines
581 XYlineVB = []
582 XYlineIA = []
583 XYlineIB = []
584 XYlineM = []
585 XYlineMX = []
586 XYlineMY = []
587 XYRlineVA = [] # XY reference trace lines
588 XYRlineVB = []
589 XYRlineIA = []
590 XYRlineIB = []
591 XYRlineM = []
592 XYRlineMX = []
593 XYRlineMY = []
594 Tmathline = [] # Time Math trace line
595 TMXline = [] # Time X math Trace line
596 TMYline = [] # Time Y math Trace line
597 T1VRline = [] # V reference Trace line channel A
598 T2VRline = [] # V reference Trace line channel B
599 T1IRline = [] # I reference Trace line channel A
600 T2IRline = [] # I reference Trace line channel B
601 TMRline = [] # Math reference Trace line
602 D0line = [] # Digital input 0 Trace line
603 D1line = [] # Digital input 1 Trace line
604 D2line = [] # Digital input 2 Trace line
605 D3line = [] # Digital input 3 Trace line
606 Triggerline = [] # Triggerline
607 Triggersymbol = [] # Trigger symbol
608 #
609 SHOWsamples = 4000 # Number of samples on the screen
610 SCstart = 0 # Start sample of the trace
611 HozPoss = 0.0
612 Is_Triggered = 0
613 #
614 TRACES = 1 # Number of traces 1 or 2
615 TRACESread = 0 # Number of traces that have been read from ALM
616 ScreenTrefresh = IntVar(0)
617 ScreenXYrefresh = IntVar(0)
618 #
619 NSteps = IntVar(0) # number of frequency sweep steps
620 NSteps.set(128)
621 LoopNum = IntVar(0)
622 LoopNum.set(1)
623 LastWindow = -1
624 LastSMPfft = 0
625 CurrentFreqX = X0LBP + 14
626 FBins = numpy.linspace(0, 50000, num=16384)
627 FStep = numpy.linspace(0, 16384, num=NSteps.get())
628 FSweepMode = IntVar(0)
629 FSweepCont = IntVar(0)
630 FStepSync = IntVar(0)
631 FSweepSync = IntVar(0)
632 ShowCA_VdB = IntVar(0) # curves to display variables
633 ShowCA_P = IntVar(0)
634 ShowCB_VdB = IntVar(0)
635 ShowCB_P = IntVar(0)
636 ShowMarkerBP = IntVar(0)
637 ShowCA_RdB = IntVar(0)
638 ShowCA_RP = IntVar(0)
639 ShowCB_RdB = IntVar(0)
640 ShowCB_RP = IntVar(0)
641 ShowMathBP = IntVar(0)
642 ShowRMathBP = IntVar(0)
643 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
644 FSweepAdB = []
645 FSweepBdB = []
646 FSweepAPh = []
647 FSweepBPh = []
648 NSweepSeriesR = []
649 NSweepSeriesX = []
650 NSweepSeriesMag = [] # in ohms
651 NSweepSeriesAng = [] # in degrees
652 NSweepParallelR = []
653 NSweepParallelC = []
654 NSweepParallelL = []
655 NSweepSeriesC = []
656 NSweepSeriesL = []
657 NetworkScreenStatus = IntVar(0)
658 BDSweepFile = IntVar(0)
659 FileSweepFreq = []
660 FileSweepAmpl = []
661 #
662 MarkerNum = MarkerFreqNum = 0
663 ShowTCur = IntVar(0)
664 ShowVCur = IntVar(0)
665 TCursor = VCursor = 0
666 ShowXCur = IntVar(0)
667 ShowYCur = IntVar(0)
668 XCursor = YCursor = 0
669 ShowFCur = IntVar(0)
670 ShowdBCur = IntVar(0)
671 FCursor = dBCursor = 0
672 ShowBPCur = IntVar(0)
673 ShowBdBCur = IntVar(0)
674 BPCursor = BdBCursor = 0
675 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
676 PowerStatus = 1
677 TRIGGERsample = 0 # AD sample trigger point
678 DX = 0 # interpolated trigger point
679 
680 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
681 DBdivindex = IntVar(0) # 10 dB/div as initial value
682 DBdivindex.set(4)
683 DBlevel = IntVar(0) # Reference level
684 DBlevel.set(0)
685 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
686 DBdivindexBP.set(4)
687 DBlevelBP = IntVar(0) # Reference level
688 DBlevelBP.set(0)
689 hldn = 0
690 SpectrumScreenStatus = IntVar(0)
691 SmoothCurvesSA = IntVar(0)
692 SmoothCurvesBP = IntVar(0)
693 CutDC = IntVar(0)
694 IAScreenStatus = IntVar(0)
695 NqPScreenStatus = IntVar(0)
696 NqPDisp = IntVar(0)
697 NiCScreenStatus = IntVar(0)
698 NiCDisp = IntVar(0)
699 ImpedanceMagnitude = 0.0 # in ohms
700 ImpedanceAngle = 0.0 # in degrees
701 ImpedanceRseries = 0.0 # in ohms
702 ImpedanceXseries = 0.0 # in ohms
703 Show_Rseries = IntVar(0)
704 Show_Xseries = IntVar(0)
705 Show_Magnitude = IntVar(0)
706 Show_Angle = IntVar(0)
707 Show_RseriesRef = IntVar(0)
708 Show_XseriesRef = IntVar(0)
709 Show_MagnitudeRef = IntVar(0)
710 Show_AngleRef = IntVar(0)
711 
712 TIARline = []
713 TIAXline = []
714 TIAMagline = []
715 TIAAngline = []
716 TIAMline = []
717 TIAMRline = []
718 RefIARline = []
719 RefIAXline = []
720 RefIAMagline = []
721 RefIAAngline = []
722 IASource = IntVar(0)
723 IAGridType = IntVar(0)
724 
725 DisplaySeries = IntVar(0)
726 IA_Ext_Conf = IntVar(0)
727 IASweepSaved = IntVar(0)
728 OverRangeFlagA = 0
729 OverRangeFlagB = 0
730 PeakdbA = 10
731 PeakdbB = 10
732 PeakRelPhase = 0.0
733 PeakfreqA = 100
734 PeakfreqB = 1000
735 OhmStatus = IntVar(0)
736 OhmRunStatus = IntVar(0)
737 FFTbandwidth = 0 # The FFT bandwidth
738 FFTBuffA = [] # Clear the FFTBuff array for trace A
739 FFTBuffB = [] # Clear the FFTBuff array for trace B
740 FFTresultA = [] # FFT result CHA
741 PhaseA = []
742 FFTresultB = [] # FFT result CHB
743 PhaseB = []
744 FFTresultAB = []
745 FFTwindowname = "--" # The FFT window name
746 FFTmemoryA = numpy.ones(1) # The memory for averaging
747 PhaseMemoryA = numpy.ones(1)
748 FFTmemoryB = numpy.ones(1) # The memory for averaging
749 PhaseMemoryB = numpy.ones(1)
750 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
751 SMPfftpwrTwo.set(11)
752 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
753 Two28 = 268435456
754 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
755 
756 T1Fline = [] # Frequency Trace line channel A
757 T2Fline = [] # Frequency Trace line channel B
758 T1Pline = [] # Phase angle Trace line channel A - B
759 T2Pline = [] # Phase angle Trace line channel B - A
760 T1FRline = [] # F reference Trace line channel A
761 T2FRline = [] # F reference Trace line channel B
762 T1PRline = [] # Phase reference Trace line channel A - B
763 T2PRline = [] # Phase reference Trace line channel B - A
764 TFMline = [] # Frequency Math Trace
765 TFRMline = [] # Frequency reference Math Trace
766 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
767 FreqTraceMode.set(1)
768 
769 TAFline = [] # Bode Freq Trace line channel A
770 TBFline = [] # Bode Freq Trace line channel B
771 TAPline = [] # Bode Phase angle Trace line channel A - B
772 TBPline = [] # Bode Phase angle Trace line channel B - A
773 TAFRline = [] # Bode F reference Trace line channel A
774 TBFRline = [] # Bode F reference Trace line channel B
775 TAPRline = [] # Bode Phase reference Trace line channel A - B
776 TBPRline = [] # Bode Phase reference Trace line channel B - A
777 TBPMline = [] # Bode Frequency Math Trace
778 TBPRMline = [] # Bode Frequency reference Math Trace
779 #
780 MinSamplesSA = 64
781 MaxSamplesSA = 65536
782 #
783 MathScreenStatus = IntVar(0)
784 #
785 XYScreenStatus = IntVar(0)
786 Xsignal = IntVar(0) # Signal for X axis variable
787 Xsignal.set(1)
788 YsignalVA = IntVar(0) # Signal for Y axis variable
789 YsignalVB = IntVar(0)
790 YsignalIA = IntVar(0)
791 YsignalIB = IntVar(0)
792 YsignalM = IntVar(0)
793 YsignalMX = IntVar(0)
794 YsignalMY = IntVar(0)
795 YsignalVB.set(1)
796 XYRefAV = IntVar(0) # show reference XY traces
797 XYRefBV = IntVar(0)
798 XYRefAI = IntVar(0)
799 XYRefBI = IntVar(0)
800 XYRefM = IntVar(0)
801 XYRefMX = IntVar(0)
802 XYRefMY = IntVar(0)
803 # show Analog Input Mux Variables
804 Show_CBA = IntVar(0)
805 Show_CBB = IntVar(0)
806 Show_CBC = IntVar(0)
807 Show_CBD = IntVar(0)
808 ShowRMA = IntVar(0)
809 ShowRMB = IntVar(0)
810 ShowRMC = IntVar(0)
811 ShowRMD = IntVar(0)
812 D0 = IntVar(0)
813 D1 = IntVar(0)
814 D2 = IntVar(0)
815 D3 = IntVar(0)
816 D4 = IntVar(0)
817 D5 = IntVar(0)
818 D6 = IntVar(0)
819 D7 = IntVar(0)
820 D0.set(0x50)
821 D1.set(0x50)
822 D2.set(0x50)
823 D3.set(0x50)
824 D4.set(0x50)
825 D5.set(0x50)
826 D6.set(0x50)
827 D7.set(0x50)
828 PIO_0 = 28
829 PIO_1 = 29
830 PIO_2 = 47
831 PIO_3 = 3
832 PIO_4 = 4
833 PIO_5 = 5
834 PIO_6 = 6
835 PIO_7 = 7
836 #
837 SCLKPort = IntVar(0)
838 SDATAPort = IntVar(0)
839 SLATCHPort = IntVar(0)
840 
841 
842 hipulse = """
843 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
844 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
845 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
846 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
847 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
848 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
849 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
850 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
851 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
852 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
853 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
854 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
855 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
856 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
857 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
858 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
859 """
860 hipulseimg = PhotoImage(data=hipulse)
861 
862 lowpulse = """
863 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
864 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
865 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
866 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
867 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
868 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
869 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
870 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
871 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
872 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
873 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
874 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
875 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
876 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
877 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
878 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
879 """
880 lowpulseimg = PhotoImage(data=lowpulse)
881 
882 class CreateToolTip(object):
883 
884  def __init__(self, widget, text='widget info'):
885  self.waittime = 500 #miliseconds
886  self.wraplength = 100 #pixels
887  self.widget = widget
888  self.text = text
889  self.widget.bind("<Enter>", self.enter)
890  self.widget.bind("<Leave>", self.leave)
891  self.widget.bind("<ButtonPress>", self.leave)
892  self.id = None
893  self.tw = None
894 
895  def enter(self, event=None):
896  self.schedule()
897 
898  def leave(self, event=None):
899  self.unschedule()
900  self.hidetip()
901 
902  def schedule(self):
903  self.unschedule()
904  self.id = self.widget.after(self.waittime, self.showtip)
905 
906  def unschedule(self):
907  id = self.id
908  self.id = None
909  if id:
910  self.widget.after_cancel(id)
911 
912  def showtip(self, event=None):
913  x = y = 0
914  x, y, cx, cy = self.widget.bbox("insert")
915  x += self.widget.winfo_rootx() + 25
916  y += self.widget.winfo_rooty() + 20
917  # creates a toplevel window
918  self.tw = Toplevel(self.widget)
919  # Leaves only the label and removes the app window
920  self.tw.wm_overrideredirect(True)
921  self.tw.wm_geometry("+%d+%d" % (x, y))
922  label = Label(self.tw, text=self.text, justify='left',
923  background="#ffffe0", foreground="#000000",
924  relief='solid', borderwidth=1,
925  wraplength = self.wraplength)
926  label.pack(ipadx=1)
927 
928  def hidetip(self):
929  tw = self.tw
930  self.tw= None
931  if tw:
932  tw.destroy()
933 
934  def configure(self, text):
935  self.text = text
936 #
937 # =========== Start widgets routines =============================
938 
940 def BSaveConfig(filename):
941  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
942  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
943  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
944  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
945  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
946  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
947  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
948  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
949  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
950  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
951  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
952  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
953  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
954  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
955  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
956  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
957  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
958  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
959  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
960  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
961  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
962  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
963  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
964  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
965  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
966  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
967  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
968  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb, ChopMuxMode, ChopTrig, DualMuxMode
969  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
970  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
971  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode, ColorMode
972  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
973  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
974  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
975  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
976  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
977  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
978  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
979  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
980  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
981  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
982  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
983  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
984  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
985  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
986  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
987  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
988  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
989  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAcsvFile, AWGBcsvFile
990  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGAwavFile, AWGBwavFile
991  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
992  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
993  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
994  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
995  global phawindow, PhAca, PhAScreenStatus, PhADisp
996  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, BoardStatus, boardwindow, BrdSel
997  global VScale, IScale, RefphEntry, EnableScopeOnly, Roll_Mode
998  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
999  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1000  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1001  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1002  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1003 
1004  # open Config file for Write?
1005  try:
1006  ConfgFile = open(filename, "w")
1007  except: # didn't work? then just return
1008  return
1009  # Save Window placements
1010  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
1011  if EnableScopeOnly == 0:
1012  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
1013  ConfgFile.write('GRW = ' + str(GRW) + '\n')
1014  ConfgFile.write('GRH = ' + str(GRH) + '\n')
1015  ConfgFile.write('ColorMode.set(' + str(ColorMode.get()) + ')\n')
1016  # Windows configuration
1017  ConfgFile.write('MathString = "' + MathString + '"\n')
1018  ConfgFile.write('MathUnits = "' + MathUnits + '"\n')
1019  ConfgFile.write('MathAxis = "' + MathAxis + '"\n')
1020  ConfgFile.write('MathXString = "' + MathXString + '"\n')
1021  ConfgFile.write('MathXUnits = "' + MathXUnits + '"\n')
1022  ConfgFile.write('MathXAxis = "' + MathXAxis + '"\n')
1023  ConfgFile.write('MathYString = "' + MathYString + '"\n')
1024  ConfgFile.write('MathYUnits = "' + MathYUnits + '"\n')
1025  ConfgFile.write('MathYAxis = "' + MathYAxis + '"\n')
1026  if BoardStatus.get() > 0:
1027  ConfgFile.write('MakeBoardScreen()\n')
1028  ConfgFile.write("boardwindow.geometry('+" + str(boardwindow.winfo_x()) + '+' + str(boardwindow.winfo_y()) + "')\n")
1029  ConfgFile.write('BrdSel.set(' + str(BrdSel.get()) + ')\n')
1030  ConfgFile.write('SelectBoard()\n')
1031  else:
1032  ConfgFile.write('DestroyBoardScreen()\n')
1033  if MathScreenStatus.get() > 0:
1034  ConfgFile.write('NewEnterMathControls()\n')
1035  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
1036  else:
1037  ConfgFile.write('DestroyMathScreen()\n')
1038  if XYScreenStatus.get() > 0:
1039  ConfgFile.write('GRWXY = ' + str(GRWXY) + '\n')
1040  ConfgFile.write('GRHXY = ' + str(GRHXY) + '\n')
1041  ConfgFile.write('MakeXYWindow()\n')
1042  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
1043  ConfgFile.write('CHAsbxy.delete(0,END)\n')
1044  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
1045  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
1046  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
1047  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
1048  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
1049  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
1050  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
1051  ConfgFile.write('CHBsbxy.delete(0,END)\n')
1052  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
1053  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
1054  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
1055  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
1056  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
1057  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
1058  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
1059  else:
1060  ConfgFile.write('DestroyXYScreen()\n')
1061  if IAScreenStatus.get() > 0:
1062  ConfgFile.write('GRWIA = ' + str(GRWIA) + '\n')
1063  ConfgFile.write('GRHIA = ' + str(GRHIA) + '\n')
1064  ConfgFile.write('MakeIAWindow()\n')
1065  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
1066  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
1067  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
1068  ConfgFile.write('RsystemEntry.delete(0,END)\n')
1069  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
1070  ConfgFile.write('ResScale.delete(0,END)\n')
1071  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
1072  ConfgFile.write('GainCorEntry.delete(0,END)\n')
1073  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
1074  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
1075  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
1076  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
1077  else:
1078  ConfgFile.write('DestroyIAScreen()\n')
1079  if SpectrumScreenStatus.get() > 0:
1080  ConfgFile.write('GRWF = ' + str(GRWF) + '\n')
1081  ConfgFile.write('GRHF = ' + str(GRHF) + '\n')
1082  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1083  ConfgFile.write('MakeSpectrumWindow()\n')
1084  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
1085  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
1086  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
1087  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
1088  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
1089  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
1090  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
1091  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
1092  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
1093  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
1094  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
1095  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
1096  else:
1097  ConfgFile.write('DestroySpectrumScreen()\n')
1098  #
1099  if DacScreenStatus.get() > 0:
1100  ConfgFile.write('MakeDacScreen()\n')
1101  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
1102  else:
1103  ConfgFile.write('DestroyDacScreen()\n')
1104  if DigScreenStatus.get() > 0:
1105  ConfgFile.write('MakeDigScreen()\n')
1106  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
1107  else:
1108  ConfgFile.write('DestroyDigScreen()\n')
1109  if EnableHSsampling > 0:
1110  ConfgFile.write('FminEntry.delete(0,"end")\n')
1111  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
1112  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
1113  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
1114  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
1115  try:
1116  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
1117  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
1118  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
1119  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
1120  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
1121  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
1122  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
1123  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
1124  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
1125  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
1126  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
1127  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
1128  except:
1129  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
1130  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
1131  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
1132  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
1133  if DigFiltStatus.get() == 1:
1134  ConfgFile.write('MakeDigFiltWindow()\n')
1135  ConfgFile.write("digfltwindow.geometry('+" + str(digfltwindow.winfo_x()) + '+' + str(digfltwindow.winfo_y()) + "')\n")
1136  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
1137  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
1138  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
1139  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
1140  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
1141  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
1142  ConfgFile.write('AWGALenEntry.delete(0,"end")\n')
1143  ConfgFile.write('AWGALenEntry.insert(0, ' + AWGALenEntry.get() + ')\n')
1144  ConfgFile.write('AWGFiltABoxCar.set(' + str(AWGFiltABoxCar.get()) + ')\n')
1145  ConfgFile.write('AWGBLenEntry.delete(0,"end")\n')
1146  ConfgFile.write('AWGBLenEntry.insert(0, ' + AWGBLenEntry.get() + ')\n')
1147  ConfgFile.write('AWGFiltBBoxCar.set(' + str(AWGFiltBBoxCar.get()) + ')\n')
1148  ConfgFile.write('BuildBoxCarA()\n')
1149  ConfgFile.write('BuildBoxCarB()\n')
1150  ConfgFile.write('BuildAWGBoxCarA()\n')
1151  ConfgFile.write('BuildAWGBoxCarB()\n')
1152  else:
1153  ConfgFile.write('DestroyDigFiltScreen()\n')
1154  if MinigenScreenStatus.get() == 1:
1155  ConfgFile.write('MakeMinigenWindow()\n')
1156  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
1157  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
1158  ConfgFile.write('MinigenFout.delete(0,END)\n')
1159  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
1160  ConfgFile.write('MinigenFclk.delete(0,END)\n')
1161  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
1162  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
1163  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
1164  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
1165  else:
1166  ConfgFile.write('DestroyMinigenScreen()\n')
1167  if MuxScreenStatus.get() == 1:
1168  ConfgFile.write('MakeMuxModeWindow()\n')
1169  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
1170  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
1171  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
1172  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
1173  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
1174  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
1175  ConfgFile.write('DualMuxMode.set(' + str(DualMuxMode.get()) + ')\n')
1176  ConfgFile.write('ChopMuxMode.set(' + str(ChopMuxMode.get()) + ')\n')
1177  ConfgFile.write('ChopTrig.set(' + str(ChopTrig.get()) + ')\n')
1178  ConfgFile.write('CHB_Asb.delete(0,END)\n')
1179  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
1180  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
1181  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1182  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1183  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1184  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1185  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1186  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1187  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1188  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1189  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1190  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1191  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1192  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1193  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1194  else:
1195  ConfgFile.write('DestroyMuxScreen()\n')
1196  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1197  if PhAScreenStatus.get() > 0:
1198  ConfgFile.write('GRWPhA = ' + str(GRWPhA) + '\n')
1199  ConfgFile.write('GRHPhA = ' + str(GRHPhA) + '\n')
1200  ConfgFile.write('MakePhAWindow()\n')
1201  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1202  ConfgFile.write('VScale.delete(0,END)\n')
1203  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1204  ConfgFile.write('IScale.delete(0,END)\n')
1205  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1206  ConfgFile.write('RefphEntry.delete(0,END)\n')
1207  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1208  if vat_btn.config('text')[-1] == 'OFF':
1209  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1210  else:
1211  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1212  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1213  if vbt_btn.config('text')[-1] == 'OFF':
1214  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1215  else:
1216  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1217  if vabt_btn.config('text')[-1] == 'OFF':
1218  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1219  else:
1220  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1221  else: # But these do
1222  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1223  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1224  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1225  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1226  if iat_btn.config('text')[-1] == 'OFF':
1227  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1228  else:
1229  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1230  if ibt_btn.config('text')[-1] == 'OFF':
1231  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1232  else:
1233  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1234  #
1235  else:
1236  ConfgFile.write('DestroyPhAScreen()\n')
1237  if BodeScreenStatus.get() == 1:
1238  ConfgFile.write('GRWBP = ' + str(GRWBP) + '\n')
1239  ConfgFile.write('GRHBP = ' + str(GRHBP) + '\n')
1240  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1241  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1242  ConfgFile.write('MakeBodeWindow()\n')
1243  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1244  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1245  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1246  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1247  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1248  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1249  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1250  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1251  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1252  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1253  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1254  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1255  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1256  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1257  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1258  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1259  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1260  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1261  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1262  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1263  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1264  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1265  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1266  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1267  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1268  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1269  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1270  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1271  else:
1272  ConfgFile.write('DestroyBodeScreen()\n')
1273  if MeasureStatus.get() == 1:
1274  # Save strings
1275  ConfgFile.write('ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1276  ConfgFile.write('ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1277  ConfgFile.write('ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1278  ConfgFile.write('ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1279  ConfgFile.write('ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1280  ConfgFile.write('ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1281  ConfgFile.write('ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1282  ConfgFile.write('ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1283  ConfgFile.write('ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1284  ConfgFile.write('ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1285  ConfgFile.write('ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1286  ConfgFile.write('ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1287  ConfgFile.write('ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1288  ConfgFile.write('ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1289  ConfgFile.write('ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1290  ConfgFile.write('ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1291  ConfgFile.write('ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1292  ConfgFile.write('ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1293  ConfgFile.write('ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1294  ConfgFile.write('ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1295  ConfgFile.write('ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1296  ConfgFile.write('ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1297  ConfgFile.write('ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1298  ConfgFile.write('ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1299  ConfgFile.write('MakeMeasureScreen()\n')
1300  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1301  else:
1302  ConfgFile.write('DestroyMeasuewScreen()\n')
1303  if ETSStatus.get() == 1: #
1304  ConfgFile.write('MakeETSWindow()\n')
1305  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1306  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1307  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1308  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1309  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1310  ConfgFile.write('DivXEntry.delete(0,END)\n')
1311  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1312  ConfgFile.write('ETSts.delete(0,END)\n')
1313  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1314  else:
1315  ConfgFile.write('DestroyETSScreen()\n')
1316  #
1317  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1318  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1319  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1320  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1321  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1322  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1323  ConfgFile.write('TMsb.delete(0,END)\n')
1324  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1325  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1326  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1327  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1328  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1329  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1330  ConfgFile.write('Roll_Mode.set(' + str(Roll_Mode.get()) + ')\n')
1331  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1332  ConfgFile.write('YsignalVA.set(' + str(YsignalVA.get()) + ')\n')
1333  ConfgFile.write('YsignalIA.set(' + str(YsignalIA.get()) + ')\n')
1334  ConfgFile.write('YsignalVB.set(' + str(YsignalVB.get()) + ')\n')
1335  ConfgFile.write('YsignalIB.set(' + str(YsignalIB.get()) + ')\n')
1336  ConfgFile.write('YsignalM.set(' + str(YsignalM.get()) + ')\n')
1337  ConfgFile.write('YsignalMX.set(' + str(YsignalMX.get()) + ')\n')
1338  ConfgFile.write('YsignalMY.set(' + str(YsignalMY.get()) + ')\n')
1339  #
1340  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1341  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1342  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1343  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1344  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1345  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1346  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1347  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1348  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1349  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1350  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1351  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1352  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1353  #
1354  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1355  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1356  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1357  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1358  ConfgFile.write('CHAsb.delete(0,END)\n')
1359  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1360  ConfgFile.write('CHAIsb.delete(0,END)\n')
1361  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1362  #
1363  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1364  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1365  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1366  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1367  ConfgFile.write('CHBsb.delete(0,END)\n')
1368  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1369  ConfgFile.write('CHBIsb.delete(0,END)\n')
1370  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1371  # AWG stuff
1372  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1373  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1374  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1375  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1376  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1377  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1378  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1379  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1380  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1381  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1382  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1383  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1384  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1385  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1386  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1387  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1388  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1389  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1390  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1391  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1392  #
1393  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1394  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1395  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1396  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1397  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1398  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1399  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1400  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1401  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1402  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1403  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1404  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1405  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1406  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1407  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1408  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1409  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1410  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1411  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1412  #
1413  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1414  ConfgFile.write('AWGAMathString = "' + AWGAMathString + '"\n')
1415  ConfgFile.write('AWGBMathString = "' + AWGBMathString + '"\n')
1416  ConfgFile.write('AWGAcsvFile = "' + AWGAcsvFile + '"\n')
1417  ConfgFile.write('AWGBcsvFile = "' + AWGBcsvFile + '"\n')
1418  ConfgFile.write('AWGAwavFile = "' + AWGAwavFile + '"\n')
1419  ConfgFile.write('AWGBwavFile = "' + AWGBwavFile + '"\n')
1420  #
1421  if EnableScopeOnly == 0:
1422  ConfgFile.write('AWGANoiseEntry.delete(0,END)\n')
1423  ConfgFile.write('AWGANoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1424  ConfgFile.write('AWGBNoiseEntry.delete(0,END)\n')
1425  ConfgFile.write('AWGBNoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1426  ConfgFile.write('AWGAsbnoise.delete(0,END)\n')
1427  ConfgFile.write('AWGAsbnoise.insert(4, "'+ str(AWGAsbnoise.get()) + '")\n')
1428  ConfgFile.write('AWGBsbnoise.delete(0,END)\n')
1429  ConfgFile.write('AWGBsbnoise.insert(4, "' + str(AWGBsbnoise.get()) + '")\n')
1430  #
1431  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1432  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1433  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1434  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1435  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1436  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1437  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1438  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1439  #
1440  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1441  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1442  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1443  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1444  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1445  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1446  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1447  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1448  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1449  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1450  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1451  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1452  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1453  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1454  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1455  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1456  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1457  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1458  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1459  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1460  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1461  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1462  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1463  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1464  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1465  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1466  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1467  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1468  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1469  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1470  #
1471  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1472  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1473  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1474  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1475  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1476  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1477  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1478  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1479  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1480  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1481  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1482  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1483  #
1484  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1485  #
1486  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1487  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1488  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1489  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1490  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1491  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1492  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1493  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1494  # Save strings
1495  ConfgFile.write('UserAString = "' + UserAString + '"\n')
1496  ConfgFile.write('UserALabel = "' + UserALabel + '"\n')
1497  ConfgFile.write('UserBString = "' + UserBString + '"\n')
1498  ConfgFile.write('UserBLabel = "' + UserBLabel + '"\n')
1499  ConfgFile.write('FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1500  ConfgFile.write('DigFilterAString = "' + DigFilterAString + '"\n')
1501  ConfgFile.write('DigFilterBString = "' + DigFilterBString + '"\n')
1502  # save channel AC frequency compensation settings
1503  try:
1504  CHA_TC1.set(float(cha_TC1Entry.get()))
1505  CHA_TC2.set(float(cha_TC2Entry.get()))
1506  CHB_TC1.set(float(chb_TC1Entry.get()))
1507  CHB_TC2.set(float(chb_TC2Entry.get()))
1508  CHA_A1.set(float(cha_A1Entry.get()))
1509  CHA_A2.set(float(cha_A2Entry.get()))
1510  CHB_A1.set(float(chb_A1Entry.get()))
1511  CHB_A2.set(float(chb_A2Entry.get()))
1512  except:
1513  donothing()
1514  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1515  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1516  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1517  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1518  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1519  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1520  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1521  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1522  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1523  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1524  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1525  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1526  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1527  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1528  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1529  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1530  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1531  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1532  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1533  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1534  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1535  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1536  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1537  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1538  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1539  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1540  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1541  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1542 
1543  # extra Spectrum stuff
1544  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1545  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1546  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1547  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1548  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1549  #
1550  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1551  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1552  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1553  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1554  #
1555  ConfgFile.close()
1556 
1558  global iawindow
1559 
1560  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1561  BSaveConfig(filename)
1562 
1564  global freqwindow
1565 
1566  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1567  BSaveConfig(filename)
1568 
1570  global bodewindow
1571 
1572  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1573  BSaveConfig(filename)
1574 
1576  global root
1577  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1578  BSaveConfig(filename)
1579 
1580 def BLoadConfig(filename):
1581  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1582  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1583  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1584  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1585  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1586  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1587  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1588  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1589  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1590  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1591  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1592  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1593  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1594  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1595  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1596  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1597  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1598  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1599  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1600  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1601  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1602  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1603  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1604  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1605  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1606  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1607  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1608  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1609  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1610  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1611  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1612  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1613  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1614  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1615  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1616  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1617  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1618  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1619  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1620  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1621  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1622  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1623  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1624  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1625  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1626  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1627  global phawindow, PhAca, PhAScreenStatus, PhADisp
1628  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1629  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1630  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1631  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1632  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1633  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1634  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1635  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1636 
1637  # Read configuration values from file
1638  try:
1639  ConfgFile = open(filename)
1640  for line in ConfgFile:
1641  try:
1642  exec( line.rstrip(), globals(), globals())
1643  #exec( line.rstrip() )
1644  except:
1645  print( "Skipping " + line.rstrip())
1646  ConfgFile.close()
1647  if ScreenWidth < root.winfo_x() or ScreenHeight < root.winfo_y(): # check if main window will be placed off screen?
1648  root.geometry('+0+0')
1649  try:
1650  if ScreenWidth < awgwindow.winfo_x() or ScreenHeight < awgwindow.winfo_y(): # check if AWG window will be placed off screen?
1651  awgwindow.geometry('+0+0')
1652  except:
1653  donothing()
1654  try:
1655  if ScreenWidth < xywindow.winfo_x() or ScreenHeight< xywindow.winfo_y(): # check if XY window will be placed off screen?
1656  xywindow.geometry('+0+0')
1657  except:
1658  donothing()
1659  try:
1660  if ScreenWidth < iawindow.winfo_x() or ScreenHeight < iawindow.winfo_y(): # check if IA window will be placed off screen?
1661  iawindow.geometry('+0+0')
1662  except:
1663  donothing()
1664  try:
1665  if ScreenWidth < freqwindow.winfo_x() or ScreenHeight < freqwindow.winfo_y(): # check if SA window will be placed off screen?
1666  freqwindow.geometry('+0+0')
1667  except:
1668  donothing()
1669  try:
1670  if ScreenWidth < win1.winfo_x() or ScreenHeight < win1.winfo_y(): # check if DAC1 window will be placed off screen?
1671  win1.geometry('+0+0')
1672  except:
1673  donothing()
1674  try:
1675  if ScreenWidth < win2.winfo_x() or ScreenHeight < win2.winfo_y(): # check if DAC2 window will be placed off screen?
1676  win2.geometry('+0+0')
1677  except:
1678  donothing()
1679  try:
1680  if ScreenWidth < minigenwindow.winfo_x() or ScreenHeight < minigenwindow.winfo_y(): # check if mini gen window will be placed off screen?
1681  minigenwindow.geometry('+0+0')
1682  except:
1683  donothing()
1684  try:
1685  if ScreenWidth < muxwindow.winfo_x() or ScreenHeight < muxwindow.winfo_y(): # check if mux window will be placed off screen?
1686  muxwindow.geometry('+0+0')
1687  except:
1688  donothing()
1689  try:
1690  if ScreenWidth < phawindow.winfo_x() or ScreenHeight < phawindow.winfo_y(): # check if PhA window will be placed off screen?
1691  phawindow.geometry('+0+0')
1692  except:
1693  donothing()
1694  try:
1695  if ScreenWidth < bodewindow.winfo_x() or ScreenHeight < bodewindow.winfo_y(): # check if Bode window will be placed off screen?
1696  bodewindow.geometry('+0+0')
1697  except:
1698  donothing()
1699  try:
1700  if ScreenWidth < measurewindow.winfo_x() or ScreenHeight < measurewindow.winfo_y(): # check if Measure window will be placed off screen?
1701  measurewindow.geometry('+0+0')
1702  except:
1703  donothing()
1704  try:
1705  if ScreenWidth < etswindow.winfo_x() or ScreenHeight < etswindow.winfo_y(): # check if ETS window will be placed off screen?
1706  etswindow.geometry('+0+0')
1707  except:
1708  donothing()
1709  if Roll_Mode.get() == 0:
1710  RollBt.config(style="RollOff.TButton",text="Roll-Off")
1711  else:
1712  RollBt.config(style="Roll.TButton",text="Roll-On")
1713  if DevID != "No Device":
1714  BAWGAModeLabel()
1715  BAWGBModeLabel()
1716  BAWGAPhaseDelay()
1717  BAWGBPhaseDelay()
1718  if ColorMode.get() > 0: # White background
1719  # print("White background")
1720  if TRACEwidth.get() < 2:
1721  TRACEwidth.set(2)
1722  COLORtext = "#000000" # 100% black
1723  COLORtrace4 = "#a0a000" # 50% yellow
1724  COLORtraceR4 = "#606000" # 25% yellow
1725  COLORcanvas = "#ffffff" # 100% white
1726  else:
1727  # print("Black background")
1728  COLORcanvas = "#000000" # 100% black
1729  COLORtrace4 = "#ffff00" # 100% yellow
1730  COLORtraceR4 = "#808000" # 50% yellow
1731  COLORtext = "#ffffff" # 100% white
1732  ca.config(background=COLORcanvas)
1733  # Needs to reload from waveform files
1734  if AWGAShape.get()==6:
1735  AWGALoadCSV()
1736  if AWGAShape.get()==13:
1737  AWGALoadWAV()
1738  if AWGBShape.get()==6:
1739  AWGBLoadCSV()
1740  if AWGBShape.get()==13:
1741  AWGBLoadWAV()
1742  # Regenerate waveform from formula
1743  if AWGAShape.get()==10:
1744  AWGAConfigMath()
1745  if AWGBShape.get()==10:
1746  AWGBConfigMath()
1747  if EnableScopeOnly == 0:
1748  UpdateAWGWin()
1749  TimeCheckBox()
1750  XYCheckBox()
1751  FreqCheckBox()
1752  BodeCheckBox()
1753  IACheckBox()
1754  OhmCheckBox()
1755  else:
1756  TimeCheckBox()
1757  XYCheckBox()
1758  UpdateAWGWin()
1759 #
1760  time.sleep(0.05)
1761  ReMakeAWGwaves()
1762  session.end() # Add this to turn off outputs after first time loading a config?
1763  BTime()
1764  except:
1765  print( "Config File Not Found.")
1766 
1767 
1768 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1769  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1770  global AWGALength, AWGBLength, AWGAwaveform, AWGBwaveform, EnableScopeOnly
1771 
1772  if AWGAShape.get()==9:
1773  AWGAMakeImpulse()
1774  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1775  elif AWGAShape.get()==11:
1777  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1778  elif AWGAShape.get()==15:
1779  AWGAMakeSSQ()
1780  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1781  elif AWGAShape.get()==16:
1782  AWGAMakeRamp()
1783  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1784  elif AWGAShape.get()==17:
1785  AWGAMakePWMSine()
1786  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1787  elif AWGAShape.get()==18:
1789  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1790  elif AWGAShape.get()==12:
1792  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1793  elif AWGAShape.get()==14:
1794  AWGAMakeFourier()
1795  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1796  elif AWGAShape.get()==19:
1797  AWGAMakeSinc()
1798  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1799  elif AWGAShape.get()==20:
1800  AWGAMakePulse()
1801  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1802  elif AWGAShape.get()==21:
1803  AWGAMakeFMSine()
1804  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1805  elif AWGAShape.get()==22:
1806  AWGAMakeAMSine()
1807  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1808  elif AWGAShape.get()==7:
1809  AWGAMakeUUNoise()
1810  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1811  elif AWGAShape.get()==8:
1812  AWGAMakeUGNoise()
1813  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1814  elif AWGAShape.get()==0:
1815  AWGAShapeLabel.config(text = "DC") # change displayed value
1816  elif AWGAShape.get()==2:
1817  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1818  elif AWGAShape.get()==4:
1819  AWGAShapeLabel.config(text = "Square") # change displayed value
1820  elif AWGAShape.get()==3:
1821  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1822  elif AWGAShape.get()==5:
1823  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1824  elif AWGAShape.get()==6:
1825  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1826  elif AWGAShape.get()==13:
1827  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1828  elif AWGAShape.get()==10:
1829  AWGAShapeLabel.config(text = "Math") # change displayed value
1830  else:
1831  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1832 #
1833  if BisCompA.get() == 1:
1834  SetBCompA()
1835  if AWGBShape.get()==9:
1836  AWGBMakeImpulse()
1837  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1838  elif AWGBShape.get()==11:
1840  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1841  elif AWGBShape.get()==15:
1842  AWGBMakeSSQ()
1843  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1844  elif AWGBShape.get()==16:
1845  AWGBMakeRamp()
1846  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1847  elif AWGBShape.get()==17:
1848  AWGBMakePWMSine()
1849  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1850  elif AWGBShape.get()==18:
1852  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1853  elif AWGBShape.get()==12:
1855  AWGBShapeLabel.config(text = "Up Down Ramp") # change displayed value
1856  elif AWGBShape.get()==14:
1857  AWGBMakeFourier()
1858  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1859  elif AWGBShape.get()==19:
1860  AWGBMakeSinc()
1861  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1862  elif AWGBShape.get()==20:
1863  AWGBMakePulse()
1864  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1865  elif AWGBShape.get()==7:
1866  AWGBMakeUUNoise()
1867  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1868  elif AWGBShape.get()==8:
1869  AWGBMakeUGNoise()
1870  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1871  elif AWGBShape.get()==0:
1872  AWGBShapeLabel.config(text = "DC") # change displayed value
1873  elif AWGBShape.get()==2:
1874  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1875  elif AWGBShape.get()==4:
1876  AWGBShapeLabel.config(text = "Square") # change displayed value
1877  elif AWGBShape.get()==3:
1878  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1879  elif AWGBShape.get()==5:
1880  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1881  elif AWGBShape.get()==6:
1882  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1883  elif AWGBShape.get()==13:
1884  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1885  elif AWGBShape.get()==10:
1886  AWGBShapeLabel.config(text = "Math") # change displayed value
1887  else:
1888  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1889  if EnableScopeOnly == 0:
1890  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
1891  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
1892  UpdateAwgCont()
1893  time.sleep(0.05)
1894 
1896  global iawindow
1897 
1898  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1899  BLoadConfig(filename)
1900 
1902  global freqwindow
1903 
1904  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1905  BLoadConfig(filename)
1906 
1908  global bodewindow
1909 
1910  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1911  BLoadConfig(filename)
1912 
1914  global root
1915 
1916  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1917  BLoadConfig(filename)
1918  UpdateTimeTrace()
1919 
1921  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
1922  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
1923  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
1924  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1925  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1926  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1927  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1928  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1929  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1930  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1931  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1932  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1933  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1934  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1935  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1936  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1937  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1938  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1939  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1940  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1941  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1942  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1943  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1944  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1945  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1946  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1947  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1948  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1949  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1950  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1951  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1952  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1953  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1954  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1955  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1956  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1957  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1958  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1959  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1960  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1961  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1962  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1963  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1964  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1965  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1966  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1967  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1968  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1969  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1970  global phawindow, PhAca, PhAScreenStatus, PhADisp
1971  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1972  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1973  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1974  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1975  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1976  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1977  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1978  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1979  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
1980 
1981  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Script files", "*.txt")], parent=root)
1982  # Read Script commands from file
1983  try:
1984  ConfgFile = open(filename)
1985  for line in ConfgFile:
1986  try:
1987  exec( line.rstrip(), globals(), globals())
1988  # exec( line.rstrip() )
1989  except:
1990  print( "Skipping " + line.rstrip())
1991  showwarning("Syntax Error!",("Syntax Error found in line:\n " + line.rstrip()))
1992  ConfgFile.close()
1993  except:
1994  print( "Config File Not Found.")
1995  showwarning("Warning!","Script File Not Found.")
1996 
1997 
1998 def BgColor():
1999  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
2000  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
2001  global COLORtrace4, COLORtraceR4, TRACEwidth
2002 
2003  if ColorMode.get() > 0: # White background
2004  if TRACEwidth.get() < 2:
2005  TRACEwidth.set(2)
2006  COLORtext = "#000000" # 100% black
2007  COLORtrace4 = "#a0a000" # 50% yellow
2008  COLORtraceR4 = "#606000" # 25% yellow
2009  COLORcanvas = "#ffffff" # 100% white
2010  else:
2011  COLORcanvas = "#000000" # 100% black
2012  COLORtrace4 = "#ffff00" # 100% yellow
2013  COLORtraceR4 = "#808000" # 50% yellow
2014  COLORtext = "#ffffff" # 100% white
2015  ca.config(background=COLORcanvas)
2017  if SpectrumScreenStatus.get() > 0:
2018  Freqca.config(background=COLORcanvas)
2020  if XYScreenStatus.get() > 0:
2021  XYca.config(background=COLORcanvas)
2022  UpdateXYScreen()
2023  if PhAScreenStatus.get() > 0:
2024  PhAca.config(background=COLORcanvas)
2025  UpdatePhAScreen()
2026  if IAScreenStatus.get() > 0:
2027  IAca.config(background=COLORcanvas)
2028  UpdateIAScreen()
2029  if BodeScreenStatus.get() > 0:
2030  Bodeca.config(background=COLORcanvas)
2032 
2034  global CANVASwidth, CANVASheight
2035  global COLORtext, MarkerNum, ColorMode
2036  # ask for file name
2037  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
2038  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
2039  if MarkerNum > 0 or ColorMode.get() > 0:
2040  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2041  else: # temp chnage text corlor to black
2042  COLORtext = "#000000"
2044  # first save postscript file
2045  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2046  # now convert to bit map
2047  # img = Image.open("screen_shot.eps")
2048  # img.save("screen_shot.gif", "gif")
2049  COLORtext = "#ffffff"
2051 
2053  global CANVASwidthXY, CANVASheightXY, xywindow
2054  global COLORtext, MarkerNum, ColorMode, XYca
2055  # ask for file name
2056  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
2057  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
2058  if MarkerNum > 0 or ColorMode.get() > 0:
2059  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2060  else: # temp chnage text corlor to black
2061  COLORtext = "#000000"
2062  UpdateXYScreen()
2063  # first save postscript file
2064  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2065  # now convert to bit map
2066  # img = Image.open("screen_shot.eps")
2067  # img.save("screen_shot.gif", "gif")
2068  COLORtext = "#ffffff"
2069  UpdateXYScreen()
2070 
2072  global CANVASwidthIA, CANVASheightIA
2073  global COLORtext, IAca, ColorMode, iawindow
2074  # ask for file name
2075  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
2076  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
2077  if ColorMode.get() > 0:
2078  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2079  else: # temp change text color to black for Black BG
2080  COLORtext = "#000000"
2081  UpdateIAScreen()
2082  # save postscript file
2083  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2084  #
2085  COLORtext = "#ffffff"
2086  UpdateIAScreen()
2087 
2089  global CANVASwidthBP, CANVASheightBP
2090  global COLORtext, Bodeca, bodewindow
2091  # ask for file name
2092  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
2093  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
2094  if MarkerNum > 0 or ColorMode.get() > 0:
2095  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2096  else: # temp change text color to black
2097  COLORtext = "#000000"
2099  # save postscript file
2100  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2101  #
2102  COLORtext = "#ffffff"
2104 
2106  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
2107 
2108  # open file to save data
2109  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2110  DataFile = open(filename, 'w')
2111  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
2112  for index in range(len(VBuffA)):
2113  TimePnt = float((index+0.0)/SAMPLErate)
2114  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
2115  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
2116  DataFile.close()
2117 
2119  global SAMPLErate, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2120  # open file to save data
2121  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2122  DataFile = open(filename, 'w')
2123  DataFile.write( 'Sample-#, MuxA, MuxB, MuxC, MuxD \n' )
2124 
2125  for index in range(len(VBuffMA)):
2126  TimePnt = float((index+0.0)/SAMPLErate)
2127  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + ', ' + str(VBuffMB[index]) + ', '
2128  + str(VBuffMC[index]) + ', ' + str(VBuffMD[index]) + '\n')
2129  DataFile.close()
2130 
2131 
2133  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2134 
2135  # ask user for channel to save
2136  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I, CB-I\n MuxA, MuxB, MuxC, MuxD \n Channel:\n", initialvalue="CA-V")
2137  if (Channel == None): # If Cancel pressed, then None
2138  return
2139  # open file to save data
2140  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2141  DataFile = open(filename, 'w')
2142  if Channel == "CA-V":
2143  DataFile.write( 'Sample-#, CA-V\n' )
2144  for index in range(len(VBuffA)):
2145  TimePnt = float((index+0.0)/SAMPLErate)
2146  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
2147  elif Channel == "CA-I":
2148  DataFile.write( 'Sample-#, CA-I,\n' )
2149  for index in range(len(IBuffA)):
2150  TimePnt = float((index+0.0)/SAMPLErate)
2151  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
2152  elif Channel == "CB-V":
2153  DataFile.write( 'Sample-#, CB-V\n' )
2154  for index in range(len(VBuffB)):
2155  TimePnt = float((index+0.0)/SAMPLErate)
2156  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
2157  elif Channel == "CB-I":
2158  DataFile.write( 'Sample-#, CB-I,\n' )
2159  for index in range(len(IBuffB)):
2160  TimePnt = float((index+0.0)/SAMPLErate)
2161  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
2162  elif Channel == "MuxA":
2163  DataFile.write( 'Sample-#, MuxA\n' )
2164  for index in range(len(VBuffMA)):
2165  TimePnt = float((index+0.0)/SAMPLErate)
2166  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + '\n')
2167  elif Channel == "MuxB":
2168  DataFile.write( 'Sample-#, MuxB\n' )
2169  for index in range(len(VBuffMB)):
2170  TimePnt = float((index+0.0)/SAMPLErate)
2171  DataFile.write( str(TimePnt) + ', ' + str(VBuffMB[index]) + '\n')
2172  elif Channel == "MuxC":
2173  DataFile.write( 'Sample-#, MuxC\n' )
2174  for index in range(len(VBuffMC)):
2175  TimePnt = float((index+0.0)/SAMPLErate)
2176  DataFile.write( str(TimePnt) + ', ' + str(VBuffMC[index]) + '\n')
2177  elif Channel == "MuxD":
2178  DataFile.write( 'Sample-#, MuxD\n' )
2179  for index in range(len(VBuffMD)):
2180  TimePnt = float((index+0.0)/SAMPLErate)
2181  DataFile.write( str(TimePnt) + ', ' + str(VBuffMD[index]) + '\n')
2182  DataFile.close()
2183 # place text string on clipboard
2184 def BSaveToClipBoard(TempBuffer):
2185  global VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD, SAMPLErate
2186 
2187  root.clipboard_clear()
2188  for index in range(len(TempBuffer)):
2189  root.clipboard_append(str(TempBuffer[index])+ '\n')
2190  root.update()
2191 
2192 # Get text string from clipboard
2194 
2195  TempBuffer = []
2196  try:
2197  clip_text = root.clipboard_get()
2198  TempBuffer = numpy.fromstring( clip_text, dtype=float, sep='\n' )
2199  return(TempBuffer)
2200  except:
2201  return(TempBuffer)
2202 
2204  global DFiltACoef
2205 
2206  DFiltACoef = BReadFromClipboard()
2207  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
2208 
2210  global DFiltBCoef
2211 
2212  DFiltBCoef = BReadFromClipboard()
2213  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
2214 
2216  global AWGFiltACoef
2217 
2218  AWGFiltACoef = BReadFromClipboard()
2219  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
2220 
2222  global AWGFiltBCoef
2223 
2224  AWGFiltBCoef = BReadFromClipboard()
2225  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
2226 
2227 
2229  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
2230 
2231  # Read values from CVS file
2232  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
2233  try:
2234  CSVFile = open(filename)
2235  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
2236  CSVFile.seek(0)
2237  csv_f = csv.reader(CSVFile, dialect)
2238  VBuffA = []
2239  VBuffB = []
2240  IBuffA = []
2241  IBuffB = []
2242  SHOWsamples = 0
2243  for row in csv_f:
2244  try:
2245  VBuffA.append(float(row[1]))
2246  IBuffA.append(float(row[2]))
2247  VBuffB.append(float(row[3]))
2248  IBuffB.append(float(row[4]))
2249  SHOWsamples = SHOWsamples + 1
2250  except:
2251  print( 'skipping non-numeric row')
2252  VBuffA = numpy.array(VBuffA)
2253  IBuffA = numpy.array(IBuffA)
2254  VBuffB = numpy.array(VBuffB)
2255  IBuffB = numpy.array(IBuffB)
2256  CSVFile.close()
2257  UpdateTimeTrace()
2258  except:
2259  showwarning("WARNING","No such file found or wrong format!")
2260 
2262 def BHelp():
2263 
2264  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
2265  webbrowser.open(url,new=2)
2266 
2267 def BAbout():
2268  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
2269 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
2270  try:
2271  if sys.version_info[0] == 2:
2272  u = urllib2.urlopen(Version_url)
2273  if sys.version_info[0] == 3:
2274  u = urllib.request.urlopen(Version_url)
2275  meta = u.info()
2276  time_string = str(meta.getheaders("Last-Modified"))
2277  except:
2278  time_string = "Unavailable"
2279  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
2280  "Last Released Version: " + time_string[7:18] + "\n" +
2281  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
2282  "Firmware Rev " + str(FWRevOne) + "\n" +
2283  "Board Serial Number " + DevID + "\n" +
2284  "Software is provided as is without any Warranty")
2285 #
2286 
2288  global T1Vline, T2Vline, T1Iline, T2Iline
2289  global Tmathline, TMRline, TXYRline
2290  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
2291  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
2292  global MuxScreenStatus, TMARline, TMBRline, TMCRline, TMDRline
2293  global TMAVline, TMBVline, TMCVline, TMDVline
2294  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
2295  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
2296 
2297  if ShowC1_V.get() == 1:
2298  T1VRline = T1Vline # V reference Trace line channel A
2299  if ShowC2_V.get() == 1:
2300  T2VRline = T2Vline # V reference Trace line channel B
2301  if ShowC1_I.get() == 1:
2302  T1IRline = T1Iline # I reference Trace line channel A
2303  if ShowC2_I.get() == 1:
2304  T2IRline = T2Iline # I reference Trace line channel B
2305  if MathTrace.get() > 0:
2306  TMRline = Tmathline # Math reference Trace line
2307  if MuxScreenStatus.get() > 0:
2308  if Show_CBA.get() > 0:
2309  TMARline = TMAVline # V reference Trace line Mux channel A
2310  if Show_CBB.get() > 0:
2311  TMBRline = TMBVline # V reference Trace line Mux channel B
2312  if Show_CBC.get() > 0:
2313  TMCRline = TMCVline # V reference Trace line Mux channel C
2314  if Show_CBD.get() > 0:
2315  TMDRline = TMDVline # V reference Trace line Mux channel D
2316 #
2317 
2319  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY
2320  global XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
2321 
2322  if len(XYlineVA) > 4:
2323  XYRlineVA = XYlineVA
2324  if len(XYlineVB) > 4:
2325  XYRlineVB = XYlineVB
2326  if len(XYlineIA) > 4:
2327  XYRlineIA = XYlineIA
2328  if len(XYlineIB) > 4:
2329  XYRlineIB = XYlineIB
2330  if len(XYlineM) > 4:
2331  XYRlineM = XYlineM
2332  if len(XYlineMX) > 4:
2333  XYRlineMX = XYlineMX
2334  if len(XYlineMY) > 4:
2335  XYRlineMY = XYlineMY
2336 #
2337 
2338 def BSaveCal():
2339  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2340  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2341  global DevID
2342  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2343  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2344  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2345  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2346 
2347  devidstr = DevID[17:31]
2348  filename = devidstr + "_O.cal"
2349  CalFile = open(filename, "w")
2350  #
2351  CalFile.write('CHAVGainEntry.delete(0,END)\n')
2352  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
2353  CalFile.write('CHBVGainEntry.delete(0,END)\n')
2354  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
2355  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
2356  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
2357  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
2358  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
2359  #
2360  CalFile.write('CHAIGainEntry.delete(0,END)\n')
2361  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
2362  CalFile.write('CHBIGainEntry.delete(0,END)\n')
2363  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
2364  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
2365  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
2366  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
2367  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
2368  #
2369  # save channel AC frequency compensation settings
2370  try:
2371  CHA_TC1.set(float(cha_TC1Entry.get()))
2372  CHA_TC2.set(float(cha_TC2Entry.get()))
2373  CHB_TC1.set(float(chb_TC1Entry.get()))
2374  CHB_TC2.set(float(chb_TC2Entry.get()))
2375  CHA_A1.set(float(cha_A1Entry.get()))
2376  CHA_A2.set(float(cha_A2Entry.get()))
2377  CHB_A1.set(float(chb_A1Entry.get()))
2378  CHB_A2.set(float(chb_A2Entry.get()))
2379  except:
2380  donothing()
2381  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
2382  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
2383  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
2384  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
2385  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
2386  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
2387  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
2388  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
2389  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
2390  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
2391  CalFile.write('cha_TC1Entry.delete(0,END)\n')
2392  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
2393  CalFile.write('cha_TC2Entry.delete(0,END)\n')
2394  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
2395  CalFile.write('chb_TC1Entry.delete(0,END)\n')
2396  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
2397  CalFile.write('chb_TC2Entry.delete(0,END)\n')
2398  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
2399  CalFile.write('cha_A1Entry.delete(0,END)\n')
2400  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
2401  CalFile.write('cha_A2Entry.delete(0,END)\n')
2402  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
2403  CalFile.write('chb_A1Entry.delete(0,END)\n')
2404  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
2405  CalFile.write('chb_A2Entry.delete(0,END)\n')
2406  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
2407 
2408  CalFile.close()
2409 
2410 def BLoadCal():
2411  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2412  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2413  global DevID
2414  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2415  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2416  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2417  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2418 
2419  devidstr = DevID[17:31]
2420  filename = devidstr + "_O.cal"
2421  try:
2422  CalFile = open(filename)
2423  for line in CalFile:
2424  exec( line.rstrip() )
2425  CalFile.close()
2426  except:
2427  print( "Cal file for this device not found")
2428 
2430  global UserAString, UserALabel, MeasUserA
2431 
2432  TempString = UserALabel
2433  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
2434  if (UserALabel == None): # If Cancel pressed, then None
2435  MeasUserA.set(0)
2436  UserALabel = TempString
2437  return
2438  TempString = UserAString
2439  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
2440  if (UserAString == None): # If Cancel pressed, then None
2441  MeasUserA.set(0)
2442  UserAString = TempString
2443  return
2444  MeasUserA.set(1)
2445 
2447  global UserBString, UserBLabel, MeasUserB
2448 
2449  TempString = UserBLabel
2450  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
2451  if (UserBLabel == None): # If Cancel pressed, then None
2452  MeasUserB.set(0)
2453  UserBLabel = TempString
2454  return
2455  TempString = UserBString
2456  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
2457  if (UserBString == None): # If Cancel pressed, then None
2458  MeasUserB.set(0)
2459  UserBString = TempString
2460  return
2461  MeasUserB.set(1)
2462 #
2463 
2465  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
2466 
2467  TempString = PlotLabelText
2468  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
2469  if (PlotLabelText == None): # If Cancel pressed, then None
2470  LabelPlotText.set(0)
2471  PlotLabelText = TempString
2472  return
2473  LabelPlotText.set(1)
2474 
2476  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
2477  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
2478  global MathAxis, MathXAxis, MathYAxis, MathTrace
2479  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
2480  global formlab, xformlab, yformlab, FrameBG
2481  global Mframe1, Mframe2, Mframe3, Mframe4
2482 
2483  if MathScreenStatus.get() == 0:
2484  MathScreenStatus.set(1)
2485  #
2486  MathWindow = Toplevel()
2487  MathWindow.title("Math Formula " + SWRev + RevDate)
2488  MathWindow.resizable(FALSE,FALSE)
2489  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
2490  MathWindow.configure(background=FrameBG)
2491  Mframe1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10T5.TLabelframe") #"A10T5.TLabelframe")
2492  Mframe2 = LabelFrame(MathWindow, text="Math Trace", style="A10T5.TLabelframe")
2493  Mframe3 = LabelFrame(MathWindow, text="X Math Trace", style="A10T6.TLabelframe")
2494  Mframe4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10T7.TLabelframe")
2495  # frame1.grid(row=0, column=0, sticky=W)
2496  #
2497  Mframe1.grid(row = 0, column=0, rowspan=3, sticky=W)
2498  Mframe2.grid(row = 0, column=1, sticky=W)
2499  Mframe3.grid(row = 1, column=1, sticky=W)
2500  Mframe4.grid(row = 2, column=1, sticky=W)
2501  #
2502  # Built in functions
2503  #
2504  mrb1 = Radiobutton(Mframe1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
2505  mrb1.grid(row=0, column=0, sticky=W)
2506  mrb2 = Radiobutton(Mframe1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
2507  mrb2.grid(row=1, column=0, sticky=W)
2508  mrb3 = Radiobutton(Mframe1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
2509  mrb3.grid(row=2, column=0, sticky=W)
2510  mrb4 = Radiobutton(Mframe1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2511  mrb4.grid(row=3, column=0, sticky=W)
2512  mrb5 = Radiobutton(Mframe1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2513  mrb5.grid(row=4, column=0, sticky=W)
2514  mrb6 = Radiobutton(Mframe1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2515  mrb6.grid(row=5, column=0, sticky=W)
2516  mrb7 = Radiobutton(Mframe1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2517  mrb7.grid(row=6, column=0, sticky=W)
2518  mrb8 = Radiobutton(Mframe1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2519  mrb8.grid(row=7, column=0, sticky=W)
2520  mrb9 = Radiobutton(Mframe1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2521  mrb9.grid(row=8, column=0, sticky=W)
2522  mrb10 = Radiobutton(Mframe1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2523  mrb10.grid(row=9, column=0, sticky=W)
2524  mrb11 = Radiobutton(Mframe1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2525  mrb11.grid(row=10, column=0, sticky=W)
2526  mrb12 = Radiobutton(Mframe1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2527  mrb12.grid(row=11, column=0, sticky=W)
2528  mrb13 = Radiobutton(Mframe1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2529  mrb13.grid(row=12, column=0, sticky=W)
2530  #
2531  # Math trace formula sub Mframe2
2532  #
2533  sframe2a = Frame( Mframe2 )
2534  sframe2a.pack(side=TOP)
2535  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2536  formlab.pack(side=LEFT)
2537  formentry = Entry(sframe2a, width=23)
2538  formentry.pack(side=LEFT)
2539  formentry.delete(0,"end")
2540  formentry.insert(0,MathString)
2541  sframe2b = Frame( Mframe2 )
2542  sframe2b.pack(side=TOP)
2543  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2544  unitslab.pack(side=LEFT)
2545  unitsentry = Entry(sframe2b, width=6)
2546  unitsentry.pack(side=LEFT)
2547  unitsentry.delete(0,"end")
2548  unitsentry.insert(0,MathUnits)
2549  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2550  checkbt.pack(side=LEFT)
2551  sframe2c = Frame( Mframe2 )
2552  sframe2c.pack(side=TOP)
2553  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2554  axislab.pack(side=LEFT)
2555  axisentry = Entry(sframe2c, width=4)
2556  axisentry.pack(side=LEFT)
2557  axisentry.delete(0,"end")
2558  axisentry.insert(0,MathAxis)
2559  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2560  applybt.pack(side=LEFT)
2561  #
2562  # X Math trace formula sub Mframe3
2563  #
2564  sframe3a = Frame( Mframe3 )
2565  sframe3a.pack(side=TOP)
2566  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2567  xformlab.pack(side=LEFT)
2568  xformentry = Entry(sframe3a, width=23)
2569  xformentry.pack(side=LEFT)
2570  xformentry.delete(0,"end")
2571  xformentry.insert(0, MathXString)
2572  sframe3b = Frame( Mframe3 )
2573  sframe3b.pack(side=TOP)
2574  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
2575  xunitslab.pack(side=LEFT)
2576  xunitsentry = Entry(sframe3b, width=6)
2577  xunitsentry.pack(side=LEFT)
2578  xunitsentry.delete(0,"end")
2579  xunitsentry.insert(0, MathXUnits)
2580  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
2581  xcheckbt.pack(side=LEFT)
2582  sframe3c = Frame( Mframe3 )
2583  sframe3c.pack(side=TOP)
2584  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
2585  xaxislab.pack(side=LEFT)
2586  xaxisentry = Entry(sframe3c, width=4)
2587  xaxisentry.pack(side=LEFT)
2588  xaxisentry.delete(0,"end")
2589  xaxisentry.insert(0, MathXAxis)
2590  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
2591  xapplybt.pack(side=LEFT)
2592  #
2593  # Math trace formula sub Mframe4
2594  #
2595  sframe4a = Frame( Mframe4 )
2596  sframe4a.pack(side=TOP)
2597  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
2598  yformlab.pack(side=LEFT)
2599  yformentry = Entry(sframe4a, width=23)
2600  yformentry.pack(side=LEFT)
2601  yformentry.delete(0,"end")
2602  yformentry.insert(0,MathYString)
2603  sframe4b = Frame( Mframe4 )
2604  sframe4b.pack(side=TOP)
2605  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
2606  yunitslab.pack(side=LEFT)
2607  yunitsentry = Entry(sframe4b, width=6)
2608  yunitsentry.pack(side=LEFT)
2609  yunitsentry.delete(0,"end")
2610  yunitsentry.insert(0,MathYUnits)
2611  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
2612  ycheckbt.pack(side=LEFT)
2613  sframe4c = Frame( Mframe4 )
2614  sframe4c.pack(side=TOP)
2615  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
2616  yaxislab.pack(side=LEFT)
2617  yaxisentry = Entry(sframe4c, width=4)
2618  yaxisentry.pack(side=LEFT)
2619  yaxisentry.delete(0,"end")
2620  yaxisentry.insert(0,MathYAxis)
2621  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
2622  yapplybt.pack(side=LEFT)
2623 
2624  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
2625  dismissbutton.grid(row=3, column=0, sticky=W)
2626 
2627  if RUNstatus.get() > 0:
2628  UpdateTimeTrace()
2629 
2631  global MathScreenStatus, MathWindow
2632 
2633  if MathScreenStatus.get() == 1:
2634  MathScreenStatus.set(0)
2635  MathWindow.destroy()
2636 
2638  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
2639  global VBuffA, VBuffB, IBuffA, IBuffB
2640  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2641  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2642  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
2643  global FFTBuffA, FFTBuffB, FFTwindowshape
2644  global AWGAwaveform, AWGBwaveform
2645  global Show_MathX, Show_MathY
2646  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2647  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2648 
2649  t = 0
2650  TempString = formentry.get()
2651  try:
2652  MathResult = eval(TempString)
2653  formlab.configure(text="Formula ", style= "A10G.TLabel")
2654  except:
2655  formlab.configure(text="Formula ", style= "A10R.TLabel")
2656 
2658  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
2659  global VBuffA, VBuffB, IBuffA, IBuffB
2660  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2661  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2662  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
2663  global FFTBuffA, FFTBuffB, FFTwindowshape
2664  global AWGAwaveform, AWGBwaveform
2665  global Show_MathX, Show_MathY
2666  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2667  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2668 
2669  t = 0
2670  TempString = xformentry.get()
2671  try:
2672  MathResult = eval(TempString)
2673  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
2674  except:
2675  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
2676 
2678  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
2679  global VBuffA, VBuffB, IBuffA, IBuffB
2680  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2681  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2682  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
2683  global FFTBuffA, FFTBuffB, FFTwindowshape
2684  global AWGAwaveform, AWGBwaveform
2685  global Show_MathX, Show_MathY
2686  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2687  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2688 
2689  t = 0
2690  TempString = yformentry.get()
2691  try:
2692  MathResult = eval(TempString)
2693  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
2694  except:
2695  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
2696 
2698  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
2699 
2700  MathString = formentry.get()
2701  MathUnits = unitsentry.get()
2702  MathAxis = axisentry.get()
2703 
2705  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
2706 
2707  MathXString = xformentry.get()
2708  MathXUnits = xunitsentry.get()
2709  MathXAxis = xaxisentry.get()
2710 
2712  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
2713 
2714  MathYString = yformentry.get()
2715  MathYUnits = yunitsentry.get()
2716  MathYAxis = yaxisentry.get()
2717 
2719  global MarkerLoc, RUNstatus
2720 
2721  TempString = MarkerLoc
2722  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
2723  if (MarkerLoc == None): # If Cancel pressed, then None
2724  MarkerLoc = TempString
2725  if RUNstatus.get() == 0: # if not running
2726  UpdateTimeTrace() # Update
2727 
2729  global RUNstatus
2730 
2731 def DoNothing(event):
2732  global RUNstatus
2733 
2735  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2736 
2737  ShowC1_V.set(1)
2738  ShowC1_I.set(1)
2739  ShowC2_V.set(1)
2740  ShowC2_I.set(1)
2741  if RUNstatus.get() == 0: # if not running
2742  UpdateTimeTrace() # Update
2743 
2745  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2746 
2747  ShowC1_V.set(0)
2748  ShowC1_I.set(0)
2749  ShowC2_V.set(0)
2750  ShowC2_I.set(0)
2751  if RUNstatus.get() == 0: # if not running
2752  UpdateTimeTrace() # Update
2753 
2755  global TgEdge
2756 
2757 # TRIGCOND trigcondRisingPositive = 0
2758 # TRIGCOND trigcondFallingNegative = 1
2759 
2761  global TgInput, TRIGGERlevel, TRIGGERentry, RUNstatus
2762  global MaxV1, MinV1, MaxV2, MinV2
2763  global MaxI1, MinI1, MaxI2, MinI2
2764  global MidVMuxA, MidVMuxB, MidVMuxC, MidVMuxD
2765  global ChopMuxMode, ChopTrig
2766  # set new trigger level to mid point of waveform
2767  MidV1 = (MaxV1+MinV1)/2
2768  MidV2 = (MaxV2+MinV2)/2
2769  MidI1 = (MaxI1+MinI1)/2
2770  MidI2 = (MaxI2+MinI2)/2
2771  if (TgInput.get() == 0):
2772  DCString = "0.0"
2773  elif (TgInput.get() == 1 or TgInput.get() == 5):
2774  DCString = ' {0:.2f} '.format(MidV1)
2775  elif (TgInput.get() == 2 ):
2776  DCString = ' {0:.2f} '.format(MidI1)
2777  elif (TgInput.get() == 3 ):
2778  DCString = ' {0:.2f} '.format(MidV2)
2779  elif (TgInput.get() == 4 ):
2780  DCString = ' {0:.2f} '.format(MidI2)
2781 #
2782  if ChopMuxMode.get() > 0:
2783  if ChopTrig.get() == 0:
2784  DCString = "0.0"
2785  if ChopTrig.get() == 1:
2786  DCString = ' {0:.2f} '.format(MidVMuxA)
2787  if ChopTrig.get() == 2:
2788  DCString = ' {0:.2f} '.format(MidVMuxB)
2789  if ChopTrig.get() == 3:
2790  DCString = ' {0:.2f} '.format(MidVMuxC)
2791  if ChopTrig.get() == 4:
2792  DCString = ' {0:.2f} '.format(MidVMuxD)
2793 #
2794  TRIGGERlevel = eval(DCString)
2795  TRIGGERentry.delete(0,END)
2796  TRIGGERentry.insert(4, DCString)
2797  if RUNstatus.get() == 0: # if not running
2798  UpdateTimeTrace() # Update
2799 
2800 
2802  global TgInput
2803 
2804 # if (TgInput.get() == 0):
2805  # no trigger
2806 # elif (TgInput.get() == 1):
2807  # trigger source set to detector of analog in channels
2808  # auto trigger timeout value
2809 # elif (TgInput.get() == 2):
2810  # trigger source set to detector of analog in channels
2811  # 0 disables auto trigger
2812 
2813 def BTriglevel(event):
2814  global TRIGGERlevel, TRIGGERentry, RUNstatus
2815 
2816  # evalute entry string to a numerical value
2817  try:
2818  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2819  except:
2820  TRIGGERentry.delete(0,END)
2821  TRIGGERentry.insert(0, TRIGGERlevel)
2822  # set new trigger level
2823  if RUNstatus.get() == 0: # if not running
2824  UpdateTimeTrace() # Update
2825 
2826 
2827 def BHoldOff(event):
2828  global HoldOff, HoldOffentry, RUNstatus
2829 
2830  try:
2831  HoldOff = float(eval(HoldOffentry.get()))
2832  except:
2833  HoldOffentry.delete(0,END)
2834  HoldOffentry.insert(0, HoldOff)
2835  if RUNstatus.get() == 0: # if not running
2836  UpdateTimeTrace() # Update
2837 # Set Horx possition from entry widget
2838 def BHozPoss(event):
2839  global HozPoss, HozPossentry, RUNstatus
2840 
2841  try:
2842  HozPoss = float(eval(HozPossentry.get()))
2843  except:
2844  HozPossentry.delete(0,END)
2845  HozPossentry.insert(0, HozPoss)
2846  if RUNstatus.get() == 0: # if not running
2847  UpdateTimeTrace() # Update
2848 #
2850  global HozPossentry, TgInput, TMsb
2851 
2852  # get time scale
2853  try:
2854  TIMEdiv = float(eval(TMsb.get()))
2855  except:
2856  TIMEdiv = 0.5
2857  TMsb.delete(0,"end")
2858  TMsb.insert(0,TIMEdiv)
2859  # prevent divide by zero error
2860  if TIMEdiv < 0.0002:
2861  TIMEdiv = 0.01
2862  if TgInput.get() > 0:
2863  HozPoss = -5 * TIMEdiv
2864  HozPossentry.delete(0,END)
2865  HozPossentry.insert(0, HozPoss)
2866 #
2868  global HoldOffentry, HoldOff, TgInput, TMsb
2869 
2870 # get time scale
2871  try:
2872  TIMEdiv = float(eval(TMsb.get()))
2873  except:
2874  TIMEdiv = 0.5
2875  TMsb.delete(0,"end")
2876  TMsb.insert(0,TIMEdiv)
2877  # prevent divide by zero error
2878  if TIMEdiv < 0.0002:
2879  TIMEdiv = 0.01
2880  if TgInput.get() == 0:
2881  HoldOff = HoldOff + TIMEdiv
2882  HoldOffentry.delete(0,END)
2883  HoldOffentry.insert(0, HoldOff)
2884 
2886  global CHB_APosEntry, DCVMuxA
2887 
2888  CHB_APosEntry.delete(0,"end")
2889  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2890 #
2892  global CHB_BPosEntry, DCVMuxB
2893 
2894  CHB_BPosEntry.delete(0,"end")
2895  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2896 #
2898  global CHB_CPosEntry, DCVMuxC
2899 
2900  CHB_CPosEntry.delete(0,"end")
2901  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2902 #
2904  global CHD_BPosEntry, DCVMuxD
2905 
2906  CHB_DPosEntry.delete(0,"end")
2907  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2908 #
2910  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2911 
2912  if MarkerScale.get() != 1:
2913  MarkerScale.set(5)
2914  CHB_Alab.config(style="Rtrace2.TButton")
2915  CHB_Blab.config(style="Strace6.TButton")
2916  CHB_Clab.config(style="Strace7.TButton")
2917  CHB_Dlab.config(style="Strace4.TButton")
2918  else:
2919  MarkerScale.set(0)
2920 #
2922  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2923 
2924  if MarkerScale.get() != 1:
2925  MarkerScale.set(6)
2926  CHB_Alab.config(style="Strace2.TButton")
2927  CHB_Blab.config(style="Rtrace6.TButton")
2928  CHB_Clab.config(style="Strace7.TButton")
2929  CHB_Dlab.config(style="Strace4.TButton")
2930  else:
2931  MarkerScale.set(0)
2932 #
2934  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2935 
2936  if MarkerScale.get() != 1:
2937  MarkerScale.set(7)
2938  CHB_Alab.config(style="Strace2.TButton")
2939  CHB_Blab.config(style="Strace6.TButton")
2940  CHB_Clab.config(style="Rtrace7.TButton")
2941  CHB_Dlab.config(style="Strace4.TButton")
2942  else:
2943  MarkerScale.set(0)
2944 #
2946  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2947 
2948  if MarkerScale.get() != 1:
2949  MarkerScale.set(8)
2950  CHB_Alab.config(style="Strace2.TButton")
2951  CHB_Blab.config(style="Strace6.TButton")
2952  CHB_Clab.config(style="Strace7.TButton")
2953  CHB_Dlab.config(style="Rtrace4.TButton")
2954  else:
2955  MarkerScale.set(0)
2956 #
2958  global CHAVPosEntry, DCV1
2959 
2960  CHAVPosEntry.delete(0,"end")
2961  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2962 #
2964  global CHBVPosEntry, DCV2
2965 
2966  CHBVPosEntry.delete(0,"end")
2967  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2968 #
2970  global CHAIPosEntry, DCI1
2971 
2972  CHAIPosEntry.delete(0,"end")
2973  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2974 #
2976  global CHBIPosEntry, DCI2
2977 
2978  CHBIPosEntry.delete(0,"end")
2979  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2980 #
2982  global CHAVPosEntryxy, DCV1
2983 
2984  CHAVPosEntryxy.delete(0,"end")
2985  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2986 #
2988  global CHBVPosEntryxy, DCV2
2989 
2990  CHBVPosEntryxy.delete(0,"end")
2991  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2992 #
2994  global CHAIPosEntryxy, DCI1
2995 
2996  CHAIPosEntryxy.delete(0,"end")
2997  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2998 #
3000  global CHBIPosEntryxy, DCI2
3001 
3002  CHBIPosEntryxy.delete(0,"end")
3003  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
3004 
3006  global RUNstatus, session, CHA, CHB, devx, AWG_2X, Closed
3007 
3008  RUNstatus.set(0)
3009  Closed = 1
3010  # BSaveConfig("alice-last-config.cfg")
3011  try:
3012  # try to write last config file, Don't crash if running in Write protected space
3013  BSaveConfig("alice-last-config.cfg")
3014  # Put channels in Hi-Z and exit
3015  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3016  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3017  devx.set_adc_mux(0) # set ADC mux conf to default
3018  AWG_2X.set(0)
3019  BAWG2X()
3020  CHA.constant(0.0)
3021  CHB.constant(0.0)
3022  devx.set_led(0b001) # Set LED.red on the way out
3023  if session.continuous:
3024  session.end()
3025  except:
3026  donothing()
3027 
3028  root.destroy()
3029  exit()
3030 
3031 def BStart():
3032  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
3033  global contloop, discontloop, TIMEdiv, First_Slow_sweep
3034  global TimeDisp, XYDisp, PhADisp, FreqDisp, BodeDisp, IADisp
3035 
3036  if DevID == "No Device":
3037  showwarning("WARNING","No Device Plugged In!")
3038  elif FWRevOne == 0.0:
3039  showwarning("WARNING","Out of data Firmware!")
3040  elif TimeDisp.get() == 0 and XYDisp.get() == 0 and PhADisp.get() == 0 and FreqDisp.get() == 0 and BodeDisp.get() == 0 and IADisp.get() == 0:
3041  showwarning("WARNING","Enable at least one Instrument!")
3042  else:
3043  if PowerStatus == 0:
3044  PowerStatus = 1
3045  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3046  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3047  if (RUNstatus.get() == 0):
3048  RUNstatus.set(1)
3049  if AWGSync.get() == 0:
3050  session.flush()
3051  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3052  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3053  BAWGEnab()
3054  if not session.continuous:
3055  session.start(0)
3056  time.sleep(0.02) # wait awhile here for some reason
3057  elif session.continuous:
3058  session.end()
3059  session.flush()
3060  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3061  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3062 
3074  BAWGEnab()
3075  else:
3076  contloop = 0
3077  discontloop = 1
3078  if session.continuous:
3079  session.end() # end continuous session mode
3080 
3081  # UpdateTimeScreen() # Always Update
3082  if TIMEdiv >= 100:
3083  First_Slow_sweep = 0
3084  else:
3085  First_Slow_sweep = 1
3086 #$ Start running Ohmmeter tool
3088  global session, AWGSync
3089 
3090  AWGSync.set(1)
3091  if AWGSync.get() == 0:
3092  session.flush()
3093  if not session.continuous:
3094  session.start(0)
3095  time.sleep(0.02) # wait awhile here for some reason
3096  elif session.continuous:
3097  session.end()
3098  session.flush()
3099  else:
3100  contloop = 0
3101  discontloop = 1
3102  if session.continuous:
3103  session.end() # end continuous session mode
3104 
3105 def BStartIA():
3106  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne, NetworkScreenStatus, BodeDisp
3107 
3108  try:
3109  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
3110  except:
3111  AWGAFreqEntry.delete(0,"end")
3112  AWGAFreqEntry.insert(0, AWGAFreqvalue)
3113  if FWRevOne > 2.16:
3114  if AWGAFreqvalue > 10000.0:
3115  Two_X_Sample.set(1)
3116  else:
3117  Two_X_Sample.set(0)
3118  SetADC_Mux()
3119  IASourceSet()
3120  if NetworkScreenStatus.get() > 0 and BodeDisp.get() > 0:
3121  BStartBP()
3122  else:
3123  BStart()
3124 
3126  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
3127 
3128  if AWGSync.get() == 0: # running in continuous mode
3129  AWGSync.set(1)
3130  if IASource.get() == 1:
3131  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
3132  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3133  AWGAMode.set(2) # Set AWG A to Hi-Z
3134  else:
3135  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
3136  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3137  AWGAMode.set(0) # Set AWG A to SVMI
3138  if AWGBIOMode.get() == 0: # if not in split I/O mode
3139  AWGBMode.set(2) # Set AWG B to Hi-Z
3140 
3141 def BStop():
3142  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
3143  global CHA, CHB, contloop, discontloop
3144 
3145  if (RUNstatus.get() == 1):
3146  # print("Stoping")
3147  RUNstatus.set(0)
3148  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3149  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3150  if AWGSync.get() == 0: # running in continuous mode
3151  CHA.constant(0.0)
3152  CHB.constant(0.0)
3153  # print("Stoping continuous mode")
3154  # session.cancel() # cancel continuous session mode while paused
3155  if session.continuous:
3156  #print( "Is Continuous? ", session.continuous)
3157  session.end()
3158  #time.sleep(0.02)
3159  #print( "Is Continuous? ", session.continuous)
3160  else:
3161  contloop = 0
3162  discontloop = 1
3163  session.cancel()
3164 #
3165  if TimeDisp.get() > 0:
3166  UpdateTimeScreen() # Always Update screens as necessary
3167  if XYDisp.get() > 0:
3168  UpdateXYScreen()
3169  if FreqDisp.get() > 0:
3171  if IADisp.get() > 0:
3172  UpdateIAScreen()
3173 
3174 def BPower():
3175  global RUNstatus, PowerStatus, devx, PwrBt
3176 
3177  if (RUNstatus.get() == 1):
3178  BStop()
3179  if PowerStatus == 1:
3180  PowerStatus = 0
3181  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
3182  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
3183  else:
3184  PowerStatus = 1
3185  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3186  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3187 
3188 def BRoll():
3189  global Roll_Mode, RollBt
3190 
3191  if Roll_Mode.get() == 1:
3192  Roll_Mode.set(0)
3193  RollBt.config(style="RollOff.TButton",text="Roll-Off")
3194  else:
3195  Roll_Mode.set(1)
3196  RollBt.config(style="Roll.TButton",text="Roll-On")
3197 
3198 
3199 def BTime():
3200  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne, ChopMuxMode
3201  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, AWGSync
3202 
3203  try: # get time scale in mSec/div
3204  TIMEdiv = float(eval(TMsb.get()))
3205  if TIMEdiv < 0.0002:
3206  TIMEdiv = 0.01
3207  TMsb.delete(0,"end")
3208  TMsb.insert(0,TIMEdiv)
3209  except:
3210  TIMEdiv = 0.5
3211  TMsb.delete(0,"end")
3212  TMsb.insert(0,TIMEdiv)
3213  # Switch to 2X sampleling if time scale small enough and not runing ETS
3214  # and not in analog input mux Chop mode.
3215  if ETSDisp.get() == 0 and ChopMuxMode.get() == 0:
3216  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
3217  if FWRevOne > 2.16:
3218  if Samples_per_div < 20.0:
3219  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
3220  if NumTraces > 2 and AWGSync.get() == 0:
3221  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
3222  BStop()
3223  Two_X_Sample.set(1)
3225  else:
3226  Two_X_Sample.set(0)
3227  SetADC_Mux()
3228  #
3229  if RUNstatus.get() == 0: # if not running
3230  UpdateTimeTrace() # Update
3231 
3233  global CHAsb, RUNstatus, CH1vpdvLevel
3234 
3235  try:
3236  CH1vpdvLevel = float(eval(CHAsb.get()))
3237  except:
3238  CHAsb.delete(0,END)
3239  CHAsb.insert(0, CH1vpdvLevel)
3240  if RUNstatus.get() == 0:
3241  UpdateTimeTrace() # if not running Update
3242 
3244  global CHAIsb, RUNstatus, CH1ipdvLevel
3245 
3246  try:
3247  CH1ipdvLevel = float(eval(CHAIsb.get()))
3248  except:
3249  CHAIsb.delete(0,END)
3250  CHAIsb.insert(0, CH1ipdvLevel)
3251  if RUNstatus.get() == 0:
3252  UpdateTimeTrace() # if not running Update
3253 
3255  global CHBsb, RUNstatus, CH2vpdvLevel
3256 
3257  try:
3258  CH2vpdvLevel = float(eval(CHBsb.get()))
3259  except:
3260  CHBsb.delete(0,END)
3261  CHBsb.insert(0, CH2vpdvLevel)
3262  if RUNstatus.get() == 0:
3263  UpdateTimeTrace() # if not running Update
3264 
3266  global CHBIsb, RUNstatus, CH2ipdvLevel
3267 
3268  try:
3269  CH2ipdvLevel = float(eval(CHBIsb.get()))
3270  except:
3271  CHBIsb.delete(0,END)
3272  CHBIsb.insert(0, CH2ipdvLevel)
3273  if RUNstatus.get() == 0:
3274  UpdateTimeTrace() # if not running Update
3275 
3276 def BOffsetA(event):
3277  global CHAOffset, CHAVPosEntry, RUNstatus
3278 
3279  try:
3280  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
3281  except:
3282  CHAVPosEntry.delete(0,END)
3283  CHAVPosEntry.insert(0, CHAOffset)
3284  # set new offset level
3285  if RUNstatus.get() == 0:
3286  UpdateTimeTrace() # if not running Update
3287 
3288 def BIOffsetA(event):
3289  global CHAIOffset, CHAIPosEntry, RUNstatus
3290 
3291  try:
3292  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
3293  except:
3294  CHAIPosEntry.delete(0,END)
3295  CHAIPosEntry.insert(0, CHAIOffset)
3296  # set new offset level
3297  if RUNstatus.get() == 0:
3298  UpdateTimeTrace() # if not running Update
3299 
3300 def BOffsetB(event):
3301  global CHBOffset, CHBVPosEntry, RUNstatus
3302 
3303  try:
3304  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
3305  except:
3306  CHBVPosEntry.delete(0,END)
3307  CHBVPosEntry.insert(0, CHBOffset)
3308  # set new offset level
3309  if RUNstatus.get() == 0:
3310  UpdateTimeTrace() # if not running Update
3311 
3312 def BIOffsetB(event):
3313  global CHBIOffset, CHBIPosEntry, RUNstatus
3314 
3315  try:
3316  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
3317  except:
3318  CHBIPosEntry.delete(0,END)
3319  CHBIPosEntry.insert(0, CHBIOffset)
3320  # set new offset level
3321  if RUNstatus.get() == 0:
3322  UpdateTimeTrace() # if not running Update
3323 
3325  global TimeDisp, ckb1
3326  if TimeDisp.get() == 1:
3327  ckb1.config(style="Enab.TCheckbutton")
3328  else:
3329  ckb1.config(style="Disab.TCheckbutton")
3330 #
3332  global XYDisp, ckb2
3333  if XYDisp.get() == 1:
3334  ckb2.config(style="Enab.TCheckbutton")
3335  else:
3336  ckb2.config(style="Disab.TCheckbutton")
3337 #
3339  global FreqDisp, ckb3, OOTckb3, OOTScreenStatus
3340  if FreqDisp.get() == 1:
3341  if OOTScreenStatus.get() == 0:
3342  ckb3.config(style="Enab.TCheckbutton")
3343  else:
3344  OOTckb3.config(style="Enab.TCheckbutton")
3345  else:
3346  if OOTScreenStatus.get() == 0:
3347  ckb3.config(style="Disab.TCheckbutton")
3348  else:
3349  OOTckb3.config(style="Disab.TCheckbutton")
3350 #
3352  global BodeDisp, ckb5, AWGSync, OOTckb5, OOTScreenStatus
3353  if BodeDisp.get() == 1:
3354  AWGSync.set(1)
3355  if OOTScreenStatus.get() == 0:
3356  ckb5.config(style="Enab.TCheckbutton")
3357  else:
3358  OOTckb5.config(style="Enab.TCheckbutton")
3359  else:
3360  if OOTScreenStatus.get() == 0:
3361  ckb5.config(style="Disab.TCheckbutton")
3362  else:
3363  OOTckb5.config(style="Disab.TCheckbutton")
3364 #
3366  global IADisp, ckb4, OOTckb4, OOTScreenStatus
3367  if IADisp.get() == 1:
3368  if OOTScreenStatus.get() == 0:
3369  ckb4.config(style="Enab.TCheckbutton")
3370  else:
3371  OOTckb4.config(style="Enab.TCheckbutton")
3372  else:
3373  if OOTScreenStatus.get() == 0:
3374  ckb4.config(style="Disab.TCheckbutton")
3375  else:
3376  OOTckb4.config(style="Disab.TCheckbutton")
3377 #
3379  global PhADisp, Phckb, OOTphckb, OOTScreenStatus
3380  if PhADisp.get() == 1:
3381  if OOTScreenStatus.get() == 0:
3382  phckb.config(style="Enab.TCheckbutton")
3383  else:
3384  OOTphckb.config(style="Enab.TCheckbutton")
3385  else:
3386  if OOTScreenStatus.get() == 0:
3387  phckb.config(style="Disab.TCheckbutton")
3388  else:
3389  OOTphckb.config(style="Disab.TCheckbutton")
3390 #
3392  global OhmDisp, ckb6, OOTckb6, OOTScreenStatus
3393  if OhmDisp.get() == 1:
3394  if OOTScreenStatus.get() == 0:
3395  ckb6.config(style="Enab.TCheckbutton")
3396  else:
3397  OOTckb6.config(style="Enab.TCheckbutton")
3398  else:
3399  if OOTScreenStatus.get() == 0:
3400  ckb6.config(style="Disab.TCheckbutton")
3401  else:
3402  OOTckb6.config(style="Disab.TCheckbutton")
3403 #
3405  global ETSDisp, enb1
3406  if ETSDisp.get() == 1:
3407  enb1.config(style="Enab.TCheckbutton")
3408  else:
3409  try:
3410  enb1.config(style="Disab.TCheckbutton")
3411  except:
3412  donothing()
3413 # ========================= Main routine ====================================
3414 
3416  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
3417  global PhADisp, IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
3418  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
3419  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
3420  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
3421  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3422  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3423  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3424  global SV1, SI1, SV2, SI2, SVA_B, Closed
3425  global FregPoint, FBins, FStep, TRACEaverage
3426  # Analog Mux channel measurement variables
3427  global TRACEresetTime, TRACEmodeTime, TgInput, SettingsStatus, TRIGGERsample
3428  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode
3429  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3430  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3431  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3432  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3433  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3434 
3435  while (Closed == 0): # Main loop
3436  # RUNstatus = 1 : Open Acquisition
3437  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
3438  if SettingsStatus.get() == 1:
3439  SettingsUpdate() # Make sure current entries in Settings controls are up to date
3440  if TimeDisp.get() > 0 or XYDisp.get() > 0 or PhADisp.get() > 0:
3441  if MuxScreenStatus.get() == 0:
3442  MuxChan = -1
3443  Analog_Time_In()
3444  else:
3445  MuxChan = 0
3446  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
3447  AWGAIOMode.set(1)
3448  AWGBIOMode.set(1)
3449  ShowC1_V.set(0) # force A voltage trace off
3450  ShowC2_V.set(0) # force B voltage trace off
3451  if HWRevOne == "D" :
3452  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
3453  AWGBMode.set(2)
3454  if AWGBIOMode.get() == 0: # if not in split I/O mode
3455  ShowC2_I.set(0) # no need to show CH-B current
3456  if MuxEnb.get() == 1:
3457  PIO2 = 0x51
3458  else:
3459  PIO2 = 0x50
3460  if MuxSync.get() == 0:
3461  PIO3 = 0x51
3462  PIO3x = 0x50
3463  else:
3464  PIO3 = 0x50
3465  PIO3x = 0x51
3466  #
3467  if ChopMuxMode.get() == 0: # do this if in alternate sweep mode
3468  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3469  TRACEresetTime = True # Clear the memory for averaging
3470  if Show_CBA.get() == 1:
3471  MuxChan = 0
3472  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3473  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3474  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
3475  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
3476  time.sleep(0.002)
3477  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3478  if TRACEmodeTime.get() == 1:
3479  if TRACEresetTime == True:
3480  TRACEresetTime = False
3481  # Save previous trace in memory for average trace
3482  VmemoryMuxA = VBuffMA
3483  Analog_Time_In()
3484  if Show_CBB.get() == 1:
3485  MuxChan = 1
3486  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3487  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3488  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3489  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3490  time.sleep(0.002)
3491  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
3492  if TRACEmodeTime.get() == 1:
3493  if TRACEresetTime == True:
3494  TRACEresetTime = False
3495  # Save previous trace in memory for average trace
3496  VmemoryMuxB = VBuffMB
3497  Analog_Time_In()
3498  if Show_CBC.get() == 1:
3499  MuxChan = 2
3500  if DualMuxMode.get() == 1:
3501  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3502  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3503  else:
3504  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3505  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3506  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3507  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3508  time.sleep(0.002)
3509  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3510  if TRACEmodeTime.get() == 1:
3511  if TRACEresetTime == True:
3512  TRACEresetTime = False
3513  # Save previous trace in memory for average trace
3514  VmemoryMuxC = VBuffMC
3515  Analog_Time_In()
3516  if Show_CBD.get() == 1:
3517  MuxChan = 3
3518  if DualMuxMode.get() == 1:
3519  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3520  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3521  else:
3522  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3523  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3524  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3525  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3526  time.sleep(0.002)
3527  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3528  if TRACEmodeTime.get() == 1:
3529  if TRACEresetTime == True:
3530  TRACEresetTime = False
3531  # Save previous trace in memory for average trace
3532  VmemoryMuxD = VBuffMD
3533  Analog_Time_In()
3534  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
3535  Analog_Time_In()
3536  else: # do this if in Chop mode
3537  MuxChan = 0
3538  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO_2 enable control
3539  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3540  TRACEresetTime = True # Clear the memory for averaging
3541  elif TRACEmodeTime.get() == 1:
3542  if TRACEresetTime == True:
3543  TRACEresetTime = False
3544  # Save previous traces in memory for average trace
3545  VmemoryMuxA = VBuffMA
3546  VmemoryMuxB = VBuffMB
3547  VmemoryMuxC = VBuffMC
3548  VmemoryMuxD = VBuffMD
3549  Analog_Time_In()
3550  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
3551  if IADisp.get() > 0 or BodeDisp.get() > 0:
3552  CutDC.set(1) # remove DC portion of waveform
3553  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
3554  if BodeDisp.get() > 0:
3555  if LoopNum.get() <= len(FStep):
3556  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3557  if FregPoint <= 5.0:
3558  SMPfft = 32768*2
3559  elif FregPoint <= 10.0:
3560  SMPfft = 32768
3561  elif FregPoint < 100.0:
3562  SMPfft = 16384
3563  elif FregPoint < 500.0:
3564  SMPfft = 8192
3565  elif FregPoint < 2000.0:
3566  SMPfft = 4096
3567  else:
3568  SMPfft = 2048
3569  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
3570  SMPfft = SMPfft * 2
3571 
3572  Analog_Freq_In()
3573  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
3574  Ohm_Analog_In()
3575  root.update_idletasks()
3576  root.update()
3577 
3579  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
3580  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
3581  global AWGAIOMode, AWGBIOMode, Two_X_Sample
3582 
3583 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3584  try:
3585  InOffA = float(eval(CHAVOffsetEntry.get()))
3586  except:
3587  CHAVOffsetEntry.delete(0,END)
3588  CHAVOffsetEntry.insert(0, InOffA)
3589  try:
3590  InGainA = float(eval(CHAVGainEntry.get()))
3591  except:
3592  CHAVGainEntry.delete(0,END)
3593  CHAVGainEntry.insert(0, InGainA)
3594  try:
3595  InOffB = float(eval(CHBVOffsetEntry.get()))
3596  except:
3597  CHBVOffsetEntry.delete(0,END)
3598  CHBVOffsetEntry.insert(0, InOffB)
3599  try:
3600  InGainB = float(eval(CHBVGainEntry.get()))
3601  except:
3602  CHBVGainEntry.delete(0,END)
3603  CHBVGainEntry.insert(0, InGainB)
3604  try:
3605  CurOffA = float(CHAIOffsetEntry.get())
3606  except:
3607  CurOffA = 0.0
3608  try:
3609  CurOffB = float(CHBIOffsetEntry.get())
3610  except:
3611  CurOffB = 0.0
3612  try:
3613  CurGainA = float(CHAIGainEntry.get())
3614  except:
3615  CurGainA = 1.0
3616  try:
3617  CurGainB = float(CHBIGainEntry.get())
3618  except:
3619  CurGainB = 1.0
3620  try:
3621  chatestv = float(eval(CHATestVEntry.get()))
3622  if chatestv > 5.0:
3623  chatestv = 5.0
3624  CHATestVEntry.delete(0,END)
3625  CHATestVEntry.insert(0, chatestv)
3626  except:
3627  CHATestVEntry.delete(0,END)
3628  CHATestVEntry.insert(0, chatestv)
3629  try:
3630  chatestr = float(eval(CHATestREntry.get()))
3631  except:
3632  CHATestREntry.delete(0,END)
3633  CHATestREntry.insert(0, chatestr)
3634  #
3635  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
3636  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
3637  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
3638  SetADC_Mux()
3639  # set A and B channels
3640  AWGAMode.set(0) # Set AWG A to SVMI
3641  AWGAShape.set(0) # DC
3642  AWGBMode.set(2) # Set AWG B to Hi-Z
3643  AWGAIOMode.set(0) # turn off Split I/O mode
3644  AWGBIOMode.set(0) # turn off Split I/O mode
3645  AWGAOffsetEntry.delete(0,"end")
3646  AWGAOffsetEntry.insert(0, chatestv)
3647  BAWGAModeLabel()
3648  BAWGBModeLabel() # update AWG labels
3649 
3650  if RMode.get() == 0:
3651  AWGBTerm.set(0)
3652  else:
3653  AWGBTerm.set(1)
3654  #
3655  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3656  if discontloop > 0:
3657  session.flush()
3658  else:
3659  discontloop = 1
3660  time.sleep(0.01)
3661  BAWGEnab()
3662  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
3663  # time.sleep(1000.0/SHOWsamples)
3664  else: # running in continuous mode
3665  if session.continuous:
3666  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
3667  #
3668  # get_samples returns a list of values for voltage [0] and current [1]
3669  for index in range(200): # calculate average
3670  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
3671  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
3672  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
3673  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
3674 
3675  DCVA0 = DCVA0 / 200.0 # calculate average
3676  DCVB0 = DCVB0 / 200.0 # calculate average
3677  DCIA0 = DCIA0 / 200.0 # calculate average
3678  DCIB0 = DCIB0 / 200.0 # calculate average
3679  DCVA0 = (DCVA0 - InOffA) * InGainA
3680  DCVB0 = (DCVB0 - InOffB) * InGainB
3681  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
3682  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
3683  if RMode.get() == 0: # external resistor
3684  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
3685  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
3686  else: # use internal 50 ohm resistor
3687  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
3688  if DCR < 1000:
3689  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
3690  else:
3691  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
3692  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
3693  OhmA0.config(text = OhmString) # change displayed value
3694  OhmA1.config(text = IAString) # change displayed value
3695 #
3696  time.sleep(0.1)
3697  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3698 
3701  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
3702  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
3703  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
3704  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
3705  global InOffA, InGainA, InOffB, InGainB
3706  global CurOffA, CurOffB, CurGainA, CurGainB
3707  global PhADisp, PhAScreenStatus, MuxScreenStatus, ChopMuxMode
3708  global First_Slow_sweep, Roll_Mode
3709  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3710 
3711  # get time scale
3712  try:
3713  TIMEdiv = eval(TMsb.get())
3714  except:
3715  TIMEdiv = 0.5
3716  TMsb.delete(0,"end")
3717  TMsb.insert(0,TIMEdiv)
3718  if TIMEdiv < 0.0002:
3719  TIMEdiv = 0.01
3720  #
3721 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3722  try:
3723  InOffA = float(eval(CHAVOffsetEntry.get()))
3724  except:
3725  CHAVOffsetEntry.delete(0,END)
3726  CHAVOffsetEntry.insert(0, InOffA)
3727  try:
3728  InGainA = float(eval(CHAVGainEntry.get()))
3729  except:
3730  CHAVGainEntry.delete(0,END)
3731  CHAVGainEntry.insert(0, InGainA)
3732  try:
3733  InOffB = float(eval(CHBVOffsetEntry.get()))
3734  except:
3735  CHBVOffsetEntry.delete(0,END)
3736  CHBVOffsetEntry.insert(0, InOffB)
3737  try:
3738  InGainB = float(eval(CHBVGainEntry.get()))
3739  except:
3740  CHBVGainEntry.delete(0,END)
3741  CHBVGainEntry.insert(0, InGainB)
3742  try:
3743  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
3744  except:
3745  CurOffA = 0.0
3746  try:
3747  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
3748  except:
3749  CurOffB = 0.0
3750  try:
3751  CurGainA = float(CHAIGainEntry.get())
3752  except:
3753  CurGainA = 1.0
3754  try:
3755  CurGainB = float(CHBIGainEntry.get())
3756  except:
3757  CurGainB = 1.0
3758 # Dedecide which Fast or Slow sweep routine to call
3759  if Roll_Mode.get() > 0: # 200:
3760  Analog_Roll_time() # rolling trace
3761  else:
3762  First_Slow_sweep = 0
3764 #
3765  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
3766  Analog_Phase_In()
3767 #
3768 # Process captured time dmain signals to extract magnitude and phase data
3770  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
3771  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3772  global VAresult, VBresult, IAresult, IBresult, VABresult
3773  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB
3774  global VMAresult, VMBresult,VMCresult, VMDresult
3775  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
3776  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3777  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3778  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
3779  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan, ChopMuxMode
3780  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
3781  global FFTwindowshape, ZEROstuffing
3782 
3783  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
3785  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
3786  #BStop() # Force Stop loop if running
3787  #return
3788  # Do an FFT on captured voltage and current buffer
3789  StartSmp = hldn
3790  StopSmp = hldn + SMPfft
3792  REX = []
3793  PhaseVA = []
3794  PhaseIA = []
3795  PhaseIB = []
3796  # Convert list to numpy array REX for faster Numpy calculations
3797  # Take the first SMPfft samples of VBuffA
3798  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
3799 
3800  # Set Analog level display value MAX value is 5 volts for ALM1000
3801  REX = REX / 5.0
3802 
3803  # Do the FFT window function
3804  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3805  # FFT with numpy
3806  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3807  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
3808  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3809 
3810  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3811  ALL = ALL[0:le] # So take only first half of the array
3812  PhaseVA = PhaseVA[0:le]
3813  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
3814  VAresult = Totalcorr * ALL
3815  # check to see if analog Mux is being used?
3816  if MuxScreenStatus.get() == 0:
3817  PhaseVB = []
3818  PhaseVAB = []
3819  # Now VB array
3820  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
3821 
3822  # Set Analog level display value MAX value is 5 volts for ALM1000
3823  REX = REX / 5.0
3824 
3825  # Do the FFT window function
3826  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3827 
3828  # FFT with numpy
3829  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3830  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
3831  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3832 
3833  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3834  ALL = ALL[0:le] # So take only first half of the array
3835  PhaseVB = PhaseVB[0:le]
3836  RMScorr = 7.07106 / SMPfft # For rMS VOLTAGE!
3837  VBresult = RMScorr * ALL
3838 
3839  # Now VAB array
3840  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
3841  REX = REX - (DCV1-DCV2) # cut any remaining DC
3842  # Set Analog level display value MAX value is 5 volts for ALM1000
3843  REX = REX / 5.0
3844 
3845  # Do the FFT window function
3846  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3847 
3848  # FFT with numpy
3849  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3850  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
3851  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3852 
3853  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3854  ALL = ALL[0:le] # So take only first half of the array
3855  PhaseVAB = PhaseVAB[0:le]
3856  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3857  VABresult = RMScorr * ALL
3858  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() > 0:
3859  if MuxChan == 0 or ChopMuxMode.get() > 0: #
3860  PhaseVMA = []
3861  # Now VMuxA array
3862  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
3863 
3864  # Set Analog level display value MAX value is 5 volts for ALM1000
3865  REX = REX / 5.0
3866 
3867  # Do the FFT window function
3868  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3869 
3870  # FFT with numpy
3871  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3872  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
3873  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3874 
3875  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3876  ALL = ALL[0:le] # So take only first half of the array
3877  PhaseVMA = PhaseVMA[0:le]
3878  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3879  VMAresult = RMScorr * ALL
3880  if MuxChan == 1 or ChopMuxMode.get() > 0: # MuxChan = 1
3881  PhaseVMB = []
3882  # Now VMuxA array
3883  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
3884 
3885  # Set Analog level display value MAX value is 5 volts for ALM1000
3886  REX = REX / 5.0
3887 
3888  # Do the FFT window function
3889  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3890 
3891  # FFT with numpy
3892  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3893  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
3894  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3895 
3896  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3897  ALL = ALL[0:le] # So take only first half of the array
3898  PhaseVMB = PhaseVMB[0:le]
3899  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3900  VMBresult = RMScorr * ALL
3901  if MuxChan == 2 or ChopMuxMode.get() > 0: # MuxChan = 2
3902  PhaseVMC = []
3903  # Now VMuxA array
3904  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
3905 
3906  # Set Analog level display value MAX value is 5 volts for ALM1000
3907  REX = REX / 5.0
3908 
3909  # Do the FFT window function
3910  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3911 
3912  # FFT with numpy
3913  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3914  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
3915  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3916 
3917  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3918  ALL = ALL[0:le] # So take only first half of the array
3919  PhaseVMC = PhaseVMC[0:le]
3920  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3921  VMCresult = RMScorr * ALL
3922  if MuxChan == 3 or ChopMuxMode.get() > 0: # MuxChan = 3
3923  PhaseVMD = []
3924  # Now VMuxA array
3925  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
3926 
3927  # Set Analog level display value MAX value is 5 volts for ALM1000
3928  REX = REX / 5.0
3929 
3930  # Do the FFT window function
3931  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3932 
3933  # FFT with numpy
3934  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3935  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
3936  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3937 
3938  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3939  ALL = ALL[0:le] # So take only first half of the array
3940  PhaseVMD = PhaseVMD[0:le]
3941  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3942  VMDresult = RMScorr * ALL
3943  # Now IA array
3944  REX = numpy.array(IBuffA[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
3945 
3946  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3947  REX = REX / 0.5
3948 
3949  # Do the FFT window function
3950  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3951 
3952  # FFT with numpy
3953  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3954  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
3955  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3956 
3957  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3958  ALL = ALL[0:le] # So take only first half of the array
3959  PhaseIA = PhaseIA[0:le]
3960  RMScorr = 0.707106 / SMPfft # RMS For current!
3961  IAresult = RMScorr * ALL
3962 
3963  # Now IB array
3964  REX = numpy.array(IBuffB[StartSmp:StopSmp]) # -DCI2 Make a numpy arry of the list
3965 
3966  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3967  REX = REX / 0.5
3968 
3969  # Do the FFT window function
3970  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3971 
3972  # FFT with numpy
3973  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3974  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
3975  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3976 
3977  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3978  ALL = ALL[0:le] # So take only first half of the array
3979  PhaseIB = PhaseIB[0:le]
3980  RMScorr = 0.707106 / SMPfft # RMS For current!
3981  IBresult = RMScorr * ALL
3982 #
3983  UpdatePhAAll()
3984 #
3985 # Right now this is a limited attempt to plot rolling sweep.
3987  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3988  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3989  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
3990  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
3991  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3992  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3993  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3994  global CHA, CHB, session, devx, discontloop, contloop
3995  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, Roll_Mode # , ShiftPointer
3996  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3997  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, GRW
3998  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3999  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4000  global SCREENrefresh, DCrefresh
4001  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4002  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4003  global SV1, SI1, SV2, SI2, SVA_B
4004  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4005  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4006  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4007  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4008  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4009  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4010  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4011  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4012  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4013  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4014  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4015  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4016  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4017  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
4018  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4019  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4020  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4021  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4022  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4023  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4024  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4025 
4026  # Starting acquisition
4027  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
4028  #
4029  NumSamples = 10 # int(SAMPLErate/TIMEdiv)
4030  if First_Slow_sweep == 0:
4031  VBuffA = numpy.ones(GRW)
4032  VBuffB = numpy.ones(GRW)
4033  IBuffA = numpy.ones(GRW)
4034  IBuffB = numpy.ones(GRW)
4035  DBuff0 = numpy.ones(GRW)
4036  DBuff1 = numpy.ones(GRW)
4037  DBuff2 = numpy.ones(GRW)
4038  DBuff3 = numpy.ones(GRW)
4039  First_Slow_sweep = 1
4040  if len(VBuffA) != GRW:
4041  VBuffA = numpy.ones(GRW)
4042  VBuffB = numpy.ones(GRW)
4043  IBuffA = numpy.ones(GRW)
4044  IBuffB = numpy.ones(GRW)
4045  DBuff0 = numpy.ones(GRW)
4046  DBuff1 = numpy.ones(GRW)
4047  DBuff2 = numpy.ones(GRW)
4048  DBuff3 = numpy.ones(GRW)
4049  #
4050  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4051  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4052  if discontloop > 0:
4053  session.flush()
4054  else:
4055  discontloop = 1
4056  BAWGEnab()
4057  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
4058  # waite to finish then return to open termination
4059  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4060  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4061  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4062  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4063 
4064  else: # running in continuous mode
4065  if session.continuous:
4066  if MuxScreenStatus.get() > 0:
4067  devx.flush(-1, True)
4068  DummySamples = NumSamples*2
4069  if DummySamples < 10000:
4070  DummySamples = 10000
4071  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4072  ADsignal1 = devx.read(NumSamples, -1, True) # True) get samples for both channel A and B
4073  #
4074  else:
4075  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
4076  # get_samples returns a list of values for voltage [0] and current [1]
4077  for index in range(NumSamples): # calculate average
4078  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
4079  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
4080  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
4081  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
4082  DCVA0 = DCVA0/(NumSamples) # calculate V average
4083  DCVB0 = DCVB0/(NumSamples) # calculate V average
4084  DCIA0 = DCIA0/(NumSamples) # calculate I average
4085  DCIB0 = DCIB0/(NumSamples) # calculate I average
4086  #
4087  #
4088  DCVA0 = (DCVA0 - InOffA) * InGainA
4089  DCVB0 = (DCVB0 - InOffB) * InGainB
4090  DCIA0 = (DCIA0 - CurOffA) * CurGainA
4091  DCIB0 = (DCIB0 - CurOffB) * CurGainB
4092  DCIA0 = DCIA0 * 1000 # convert to mA
4093  DCIB0 = DCIB0 * 1000 # convert to mA
4094 # next new sample
4095  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
4096  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
4097  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
4098  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
4099 # Make digital input buffer if that port is an input
4100  if D0.get() == 0:
4101  DBuff0 = shift_buffer(DBuff0, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100))
4102  if D1.get() == 0:
4103  DBuff1 = shift_buffer(DBuff1, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100))
4104  if D2.get() == 0:
4105  DBuff2 = shift_buffer(DBuff2, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100))
4106  if D3.get() == 0:
4107  DBuff3 = shift_buffer(DBuff3, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100))
4108 # Calculate measurement values
4109  SampleEnd = len(VBuffA) - 1
4110  Cal_trace_scalars(0, SampleEnd)
4111 #
4112  if TimeDisp.get() > 0:
4113  MakeTimeTrace() # Update the traces
4114  UpdateTimeScreen() # Update the screen
4115  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4116  UpdateXYAll() # Update Data, trace and XY screen
4117  if MeasureStatus.get() > 0:
4119  # update screens
4120 #
4122  global ADsignal1, VBuffMA, VBuffMB, VBuffMC, VBuffMD
4123  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4124  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4125  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4126  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4127  global SHOWsamples, ChopModeFilter
4128 
4129  VBuffMA = [] # Clear the Mux A array
4130  VBuffMB = [] # Clear the Mux B array
4131  VBuffMC = [] # Clear the Mux C array
4132  VBuffMD = [] # Clear the Mux D array
4133  index = 1
4134  while index < SHOWsamples-3: # build arrays VBuffMA, VBuffMB, VBuffMC, VBuffMD
4135  pointer = 0
4136  while pointer < 4:
4137  VBuffMA.append(ADsignal1[index+3][0][0]) # chop AIN into Mux A and B
4138  VBuffMB.append(ADsignal1[index+1][0][0])
4139  VBuffMC.append(ADsignal1[index+3][1][0]) # chop BIN into Mux C and D
4140  VBuffMD.append(ADsignal1[index+1][1][0])
4141  pointer = pointer + 1
4142  index = index + 4
4143  VBuffMA = numpy.array(VBuffMA)
4144  VBuffMB = numpy.array(VBuffMB)
4145  VBuffMC = numpy.array(VBuffMC)
4146  VBuffMD = numpy.array(VBuffMD)
4147  # apply a digital filter to interpolate back to 100 KSPS
4148  VBuffMA = numpy.pad(VBuffMA, (4, 0), "edge")
4149  VBuffMA = numpy.convolve(VBuffMA, ChopModeFilter )
4150  VBuffMA = numpy.roll(VBuffMA, -4)
4151  VBuffMB = numpy.pad(VBuffMB, (4, 0), "edge")
4152  VBuffMB = numpy.convolve(VBuffMB, ChopModeFilter)
4153  VBuffMB = numpy.roll(VBuffMB, -6)
4154  VBuffMC = numpy.pad(VBuffMC, (4, 0), "edge")
4155  VBuffMC = numpy.convolve(VBuffMC, ChopModeFilter )
4156  VBuffMC = numpy.roll(VBuffMC, -4)
4157  VBuffMD = numpy.pad(VBuffMD, (4, 0), "edge")
4158  VBuffMD = numpy.convolve(VBuffMD, ChopModeFilter )
4159  VBuffMD = numpy.roll(VBuffMD, -6)
4160  # calculate waveform scalers
4161  EndSample = SHOWsamples-4
4162  DCVMuxA = numpy.mean(VBuffMA[:EndSample])
4163  MinVMuxA = numpy.amin(VBuffMA[:EndSample])
4164  MaxVMuxA = numpy.amax(VBuffMA[:EndSample])
4165  MidVMuxA = (MaxVMuxA+MinVMuxA)/2.0
4166  PPVMuxA = MaxVMuxA-MinVMuxA
4167 #
4168  DCVMuxB = numpy.mean(VBuffMB[:EndSample])
4169  MinVMuxB = numpy.amin(VBuffMB[:EndSample])
4170  MaxVMuxB = numpy.amax(VBuffMB[:EndSample])
4171  MidVMuxB = (MaxVMuxB+MinVMuxB)/2.0
4172  PPVMuxB = MaxVMuxB-MinVMuxB
4173 #
4174  DCVMuxC = numpy.mean(VBuffMC[:EndSample])
4175  MinVMuxC = numpy.amin(VBuffMC[:EndSample])
4176  MaxVMuxC = numpy.amax(VBuffMC[:EndSample])
4177  MidVMuxC = (MaxVMuxC+MinVMuxC)/2.0
4178  PPVMuxC = MaxVMuxC-MinVMuxC
4179 #
4180  DCVMuxD = numpy.mean(VBuffMD[:EndSample])
4181  MinVMuxD = numpy.amin(VBuffMD[:EndSample])
4182  MaxVMuxD = numpy.amax(VBuffMD[:EndSample])
4183  MidVMuxD = (MaxVMuxD+MinVMuxD)/2.0
4184  PPVMuxD = MaxVMuxD-MinVMuxD
4185  # RMS value = square root of average of the data record squared
4186  SVMuxA = numpy.sqrt(numpy.mean(numpy.square(VBuffMA[:EndSample])))
4187  SVMuxB = numpy.sqrt(numpy.mean(numpy.square(VBuffMB[:EndSample])))
4188  SVMuxC = numpy.sqrt(numpy.mean(numpy.square(VBuffMC[:EndSample])))
4189  SVMuxD = numpy.sqrt(numpy.mean(numpy.square(VBuffMD[:EndSample])))
4190 #
4191 # routine for time scales faster than Slow_Sweep_Limit mSec/Div
4193  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4194  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4195  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
4196  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4197  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4198  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4199  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
4200  global TRACES, TRACESread, TRACEsize, TRIGGERsampleAltA, TRIGGERsampleAltB
4201  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4202  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
4203  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
4204  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4205  global SCREENrefresh, DCrefresh, ETSrecord
4206  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4207  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4208  global SV1, SI1, SV2, SI2, SVA_B
4209  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4210  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4211  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4212  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4213  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4214  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
4215  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4216  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4217  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4218  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4219  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4220  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4221  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4222  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode, ChopTrig
4223  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4224  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4225  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4226  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4227  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4228  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4229  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4230  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4231  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
4232 
4233  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4234  TRACEresetTime = True # Clear the memory for averaging
4235  elif TRACEmodeTime.get() == 1:
4236  if TRACEresetTime == True:
4237  TRACEresetTime = False
4238  # Save previous trace in memory for average trace
4239  VmemoryA = VBuffA
4240  VmemoryB = VBuffB
4241  ImemoryA = IBuffA
4242  ImemoryB = IBuffB
4243 
4244  try:
4245  HoldOff = float(eval(HoldOffentry.get()))
4246  if HoldOff < 0:
4247  HoldOff = 0
4248  HoldOffentry.delete(0,END)
4249  HoldOffentry.insert(0, HoldOff)
4250  except:
4251  HoldOffentry.delete(0,END)
4252  HoldOffentry.insert(0, HoldOff)
4253 #
4254  try:
4255  HozPoss = float(eval(HozPossentry.get()))
4256  except:
4257  HozPossentry.delete(0,END)
4258  HozPossentry.insert(0, HozPoss)
4259 
4260  hldn = int(HoldOff * SAMPLErate/1000 )
4261  hozpos = int(HozPoss * SAMPLErate/1000 )
4262  if hozpos < 0:
4263  hozpos = 0
4264  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
4265  onescreen = int(twoscreens/2)
4266  if hldn+hozpos > MaxSamples-twoscreens:
4267  hldn = MaxSamples-twoscreens-hozpos
4268  HoldOffentry.delete(0,END)
4269  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
4270  if ETSDisp.get() > 0:
4271  if TIMEdiv > 0.2:
4272  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
4273  else:
4274  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
4275  if (MaxETSrecord*100) > MaxSamples:
4276  MaxETSrecord = MaxSamples / 100
4277  try:
4278  DivX = float(eval(DivXEntry.get()))
4279  if DivX < 2:
4280  DivX = 2
4281  if DivX > 75:
4282  DivX = 75
4283  DivXEntry.delete(0,END)
4284  DivXEntry.insert(0, DivX)
4285  except:
4286  DivXEntry.delete(0,END)
4287  DivXEntry.insert(0, DivX)
4288  FOff = 25
4289  MulX = (DivX*SAMPLErate)/(100*FOff)
4290  while MulX > MaxETSrecord:
4291  FOff = FOff + 5
4292  MulX = (DivX*SAMPLErate)/(100*FOff)
4293  FOff = 0 - FOff
4294  if DeBugMode > 0:
4295  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
4296  MulXEntry.config(text = SRstring) # change displayed value
4297  SRstring = "Offset = " + str(FOff) + " samples"
4298  FOffEntry.config(text = SRstring) # change displayed value
4299  SHOWsamples = int(MulX * 100)
4300  else:
4301  SHOWsamples = twoscreens + hldn + hozpos
4302  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
4303  SHOWsamples = MaxSamples
4304  if SHOWsamples < MinSamples: # or a Min of 1000 samples
4305  SHOWsamples = MinSamples
4306  if PhAScreenStatus.get() > 0:
4307  if SHOWsamples < SMPfft:
4308  SHOWsamples = SMPfft + hldn + hozpos
4309  if hozpos >= 0:
4310  TRIGGERsample = hldn
4311  else:
4312  TRIGGERsample = abs(hozpos)
4313  TRIGGERsample = TRIGGERsample + hozpos #
4314 # Starting acquisition
4315  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4316  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4317  if discontloop > 0:
4318  session.flush()
4319  else:
4320  discontloop = 1
4321  time.sleep(0.01)
4322  BAWGEnab()
4323  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4324  # waite to finish then return to open termination
4325  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4326  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4327  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4328  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4329  else: # running in continuous mode
4330  if session.continuous:
4331  if MuxScreenStatus.get() > 0:
4332  devx.flush(-1, True)
4333  DummySamples = SHOWsamples*2
4334  if DummySamples < 20000:
4335  DummySamples = 20000
4336  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4337  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4338  #
4339  else:
4340  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
4341  # waite to finish then return to open termination
4342  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4343  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4344  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4345  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4346  #
4347  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4348  if ADC_Mux_Mode.get() == 0: # VA and VB
4349  VBuffA = [] # Clear the V Buff array for trace A
4350  VBuffB = [] # Clear the V Buff array for trace B
4351  elif ADC_Mux_Mode.get() == 1: # IA and IB
4352  IBuffA = [] # Clear the I Buff array for trace A
4353  IBuffB = [] # Clear the I Buff array for trace B
4354  elif ADC_Mux_Mode.get() == 4: # VA and IA
4355  VBuffA = [] # Clear the V Buff array for trace A
4356  IBuffA = [] # Clear the I Buff array for trace A
4357  elif ADC_Mux_Mode.get() == 5: # VB and IB
4358  VBuffB = [] # Clear the V Buff array for trace B
4359  IBuffB = [] # Clear the I Buff array for trace B
4360  else:
4361  VBuffA = [] # Clear the V Buff array for trace A
4362  IBuffA = [] # Clear the I Buff array for trace A
4363  VBuffB = [] # Clear the V Buff array for trace B
4364  IBuffB = [] # Clear the I Buff array for trace B
4365  increment = 1
4366  # SAMPLErate = 200000 #AWGSAMPLErate
4367  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
4368  increment = 2
4369  SAMPLErate = int(AWGSAMPLErate/increment)
4370  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
4371  increment = 4
4372  SAMPLErate = int(AWGSAMPLErate/increment)
4373  index = 0
4374  if SHOWsamples != len(ADsignal1):
4375  SHOWsamples = len(ADsignal1)
4376 #
4377  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0: # check to see if Mux Chop mode is set
4379 #
4380  while index < SHOWsamples: # build arrays and decimate if needed
4381  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
4382  if ADC_Mux_Mode.get() == 0: # VA and VB
4383  VBuffA.append(ADsignal1[index][0][0])
4384  VBuffA.append(ADsignal1[index][1][1])
4385  VBuffB.append(ADsignal1[index][0][1])
4386  VBuffB.append(ADsignal1[index][1][0])
4387  if Alternate_Sweep_Mode.get() == 0:
4388  IBuffA.append(0.0) # fill as a place holder
4389  IBuffA.append(0.0) # fill as a place holder
4390  IBuffB.append(0.0) # fill as a place holder
4391  IBuffB.append(0.0) # fill as a place holder
4392  elif ADC_Mux_Mode.get() == 1: # IA and IB
4393  IBuffA.append(ADsignal1[index][0][1])
4394  IBuffA.append(ADsignal1[index][1][0])
4395  IBuffB.append(ADsignal1[index][0][0])
4396  IBuffB.append(ADsignal1[index][1][1])
4397  if Alternate_Sweep_Mode.get() == 0:
4398  VBuffA.append(0.0) # fill as a place holder
4399  VBuffA.append(0.0) # fill as a place holder
4400  VBuffB.append(0.0) # fill as a place holder
4401  VBuffB.append(0.0) # fill as a place holder
4402  elif ADC_Mux_Mode.get() == 2: # VA and IB
4403  VBuffA.append((ADsignal1[index][0][1])/1024.0)
4404  VBuffA.append((ADsignal1[index][1][0])/1024.0)
4405  #
4406  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
4407  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
4408  #
4409  if Alternate_Sweep_Mode.get() == 0:
4410  VBuffB.append(0.0) # fill as a place holder
4411  VBuffB.append(0.0) # fill as a place holder
4412  IBuffA.append(0.0) # fill as a place holder
4413  IBuffA.append(0.0) # fill as a place holder
4414  elif ADC_Mux_Mode.get() == 3: # VB and IA
4415  VBuffB.append((ADsignal1[index][0][0])/1024.0)
4416  VBuffB.append((ADsignal1[index][1][1])/1024.0)
4417  #
4418  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
4419  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
4420  #
4421  if Alternate_Sweep_Mode.get() == 0:
4422  VBuffA.append(0.0) # fill as a place holder
4423  VBuffA.append(0.0) # fill as a place holder
4424  IBuffB.append(0.0) # fill as a place holder
4425  IBuffB.append(0.0) # fill as a place holder
4426  elif ADC_Mux_Mode.get() == 4: # VA and IA
4427  VBuffA.append(ADsignal1[index][0][0])
4428  VBuffA.append(ADsignal1[index][1][1])
4429  IBuffA.append(ADsignal1[index][0][1])
4430  IBuffA.append(ADsignal1[index][1][0])
4431  if Alternate_Sweep_Mode.get() == 0:
4432  VBuffB.append(0.0) # fill as a place holder
4433  VBuffB.append(0.0) # fill as a place holder
4434  IBuffB.append(0.0) # fill as a place holder
4435  IBuffB.append(0.0) # fill as a place holder
4436  elif ADC_Mux_Mode.get() == 5: # VB and IB
4437  VBuffB.append(ADsignal1[index][0][1])
4438  VBuffB.append(ADsignal1[index][1][0])
4439  IBuffB.append(ADsignal1[index][0][0])
4440  IBuffB.append(ADsignal1[index][1][1])
4441  if Alternate_Sweep_Mode.get() == 0:
4442  VBuffA.append(0.0) # fill as a place holder
4443  VBuffA.append(0.0) # fill as a place holder
4444  IBuffA.append(0.0) # fill as a place holder
4445  IBuffA.append(0.0) # fill as a place holder
4446  else:
4447  VBuffA.append(ADsignal1[index][0][0])
4448  IBuffA.append(ADsignal1[index][0][1])
4449  VBuffB.append(ADsignal1[index][1][0])
4450  IBuffB.append(ADsignal1[index][1][1])
4451  index = index + increment
4452 #
4453  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4454  if len(VBuffA) < 4:
4455  index = 0
4456  while index < SHOWsamples:
4457  VBuffA.append(0.0) # fill as a place holder
4458  index = index + increment
4459  if len(VBuffB) < 4:
4460  index = 0
4461  while index < SHOWsamples:
4462  VBuffB.append(0.0) # fill as a place holder
4463  index = index + increment
4464  if len(IBuffA) < 4:
4465  index = 0
4466  while index < SHOWsamples:
4467  IBuffA.append(0.0) # fill as a place holder
4468  index = index + increment
4469  if len(IBuffB) < 4:
4470  index = 0
4471  while index < SHOWsamples:
4472  IBuffB.append(0.0) # fill as a place holder
4473  index = index + increment
4474 #
4475  if ADC_Mux_Mode.get() == 0: # VA and VB
4476  VBuffA = numpy.array(VBuffA)
4477  VBuffB = numpy.array(VBuffB)
4478  VBuffA = (VBuffA - InOffA) * InGainA
4479  VBuffB = (VBuffB - InOffB) * InGainB
4480  ADC_Mux_Mode.set(1) # switch mode
4481  Last_ADC_Mux_Mode = 0
4482  elif ADC_Mux_Mode.get() == 1: # IA and IB
4483  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4484  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4485  IBuffA = (IBuffA - CurOffA) * CurGainA
4486  IBuffB = (IBuffB - CurOffB) * CurGainB
4487  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
4488  elif ADC_Mux_Mode.get() == 4: # VA and IA
4489  VBuffA = numpy.array(VBuffA)
4490  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4491  IBuffA = (IBuffA - CurOffA) * CurGainA
4492  VBuffA = (VBuffA - InOffA) * InGainA
4493  ADC_Mux_Mode.set(1) # switch mode
4494  Last_ADC_Mux_Mode = 4
4495  elif ADC_Mux_Mode.get() == 5: # VB and IB
4496  VBuffB = numpy.array(VBuffB)
4497  VBuffB = (VBuffB - InOffB) * InGainB
4498  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4499  IBuffB = (IBuffB - CurOffB) * CurGainB
4500  ADC_Mux_Mode.set(1) # switch mode
4501  Last_ADC_Mux_Mode = 5
4502  SetADC_Mux()
4503  #
4504  else:
4505  VBuffA = numpy.array(VBuffA)
4506  VBuffB = numpy.array(VBuffB)
4507  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4508  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4509  VBuffA = (VBuffA - InOffA) * InGainA
4510  VBuffB = (VBuffB - InOffB) * InGainB
4511  IBuffA = (IBuffA - CurOffA) * CurGainA
4512  IBuffB = (IBuffB - CurOffB) * CurGainB
4513  TRACESread = 2
4514  SHOWsamples = len(VBuffA)
4515 # temp ETS calculations
4516  if ETSDisp.get() > 0:
4517  baseFreq = SAMPLErate/DivX
4518  #
4519  VAets = []
4520  VBets = []
4521  IAets = []
4522  IBets = []
4523  index = 0
4524  try:
4525  FMul = float(eval(FminEntry.get()))
4526  if FMul < 1:
4527  FMul = 1
4528  FMulXEntry.delete(0,END)
4529  FMulXEntry.insert(0, int(FMul))
4530  if FMul > 75:
4531  FMul = 75
4532  FMulXEntry.delete(0,END)
4533  FMulXEntry.insert(0, int(FMul))
4534  except:
4535  FMulXEntry.delete(0,END)
4536  FMulXEntry.insert(0, int(FMul))
4537  Fmin = baseFreq * FMul
4538  FminE = float(SAMPLErate + FOff)
4539  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
4540  # length of record set my Multiplcation factor
4541  tot_cycles = int((MulX*100)/Samples_Cycle)
4542  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
4543  ETSrecord = int((MulX*50)/Samples_Cycle)
4544  if tot_cycles > SHOWsamples:
4545  tot_cycles = SHOWsamples-1
4546  # now sort RT data into ETS sample buffers
4547  while index < SHOWsamples:
4548  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
4549  IndexValue = int(tot_cycles * Dpart)
4550  if IndexValue > SHOWsamples:
4551  IndexValue = SHOWsamples-1
4552  if IndexValue > tot_cycles:
4553  IndexValue = tot_cycles
4554  if ETSDir.get() == 0:
4555  VAets.append(VBuffA[IndexValue])
4556  VBets.append(VBuffB[IndexValue])
4557  IAets.append(IBuffA[IndexValue])
4558  IBets.append(IBuffB[IndexValue])
4559  else:
4560  VAets.append(VBuffA[int(tot_cycles-IndexValue)])
4561  VBets.append(VBuffB[int(tot_cycles-IndexValue)])
4562  IAets.append(IBuffA[int(tot_cycles-IndexValue)])
4563  IBets.append(IBuffB[int(tot_cycles-IndexValue)])
4564  index = index + 1
4565  SHiftFact = 5
4566  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
4567  VBuffA = VAets
4568  VBuffB = VBets
4569  IBuffA = IAets
4570  IBuffB = IBets
4571  VBuffA = numpy.array(VBuffA)
4572  VBuffB = numpy.array(VBuffB)
4573  IBuffA = numpy.array(IBuffA)
4574  IBuffB = numpy.array(IBuffB)
4575  try:
4576  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
4577  except:
4578  TimeCorrection = SHiftFact
4579  if ETSDir.get() == 0:
4580  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4581  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4582  else:
4583  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4584  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4585  SHOWsamples = twoscreens + hldn + hozpos
4586 # Check if Input channel RC high pass compensation checked
4587  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
4588  try:
4589  TC1A = float(cha_TC1Entry.get())
4590  if TC1A < 0:
4591  TC1A = 0
4592  cha_TC1Entry.delete(0,END)
4593  cha_TC1Entry.insert(0, TC1A)
4594  except:
4595  TC1A = CHA_TC1.get()
4596  try:
4597  TC2A = float(cha_TC2Entry.get())
4598  if TC2A < 0:
4599  TC2A = 0
4600  cha_TC2Entry.delete(0,END)
4601  cha_TC2Entry.insert(0, TC2A)
4602  except:
4603  TC2A = CHA_TC2.get()
4604  #
4605  try:
4606  Gain1A = float(cha_A1Entry.get())
4607  except:
4608  Gain1A = CHA_A1.get()
4609  try:
4610  Gain2A = float(cha_A2Entry.get())
4611  except:
4612  Gain2A = CHA_A2.get()
4613  #
4614  if len(VBuffA) > 4:
4615  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
4616  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
4617  if CHAI_RC_HP.get() == 1:
4618  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
4619  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
4620  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
4621  try:
4622  TC1B = float(chb_TC1Entry.get())
4623  if TC1B < 0:
4624  TC1B = 0
4625  chb_TC1Entry.delete(0, END)
4626  chb_TC1Entry.insert(0, TC1B)
4627  except:
4628  TC1B = CHB_TC1.get()
4629  try:
4630  TC2B = float(chb_TC2Entry.get())
4631  if TC2B < 0:
4632  TC2B = 0
4633  chb_TC2Entry.delete(0, END)
4634  chb_TC2Entry.insert(0, TC2B)
4635  except:
4636  TC2B = CHB_TC2.get()
4637  #
4638  try:
4639  Gain1B = float(chb_A1Entry.get())
4640  except:
4641  Gain1B = CHB_A1.get()
4642  try:
4643  Gain2B = float(chb_A2Entry.get())
4644  except:
4645  Gain2B = CHB_A2.get()
4646  #
4647  if len(VBuffB) > 4:
4648  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
4649  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
4650  if CHBI_RC_HP.get() == 1:
4651  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
4652  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
4653 # Check if need to DeSkew waveform data
4654  if DigDeSkewA.get() > 0:
4655  Shift = int(BCASkewEntry.get())
4656  if Shift != 0:
4657  VBuffA = numpy.roll(VBuffA, Shift)
4658  if DigDeSkewB.get() > 0:
4659  Shift = int(BCBSkewEntry.get())
4660  if Shift != 0:
4661  VBuffB = numpy.roll(VBuffB, Shift)
4662 # check if digital filter box checked
4663  if DigFiltA.get() == 1:
4664  if len(DFiltACoef) > 1:
4665  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
4666  if DigFiltB.get() == 1:
4667  if len(DFiltBCoef) > 1:
4668  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
4669 # Find trigger sample point if necessary
4670  LShift = 0
4671  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0:
4672  if ChopTrig.get() == 1:
4673  FindTriggerSample(VBuffMA)
4674  if ChopTrig.get() == 2:
4675  FindTriggerSample(VBuffMB)
4676  if ChopTrig.get() == 3:
4677  FindTriggerSample(VBuffMC)
4678  if ChopTrig.get() == 4:
4679  FindTriggerSample(VBuffMD)
4680  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4681  # Average mode 1, add difference / TRACEaverage to array
4682  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0:
4683  LShift = 0 - TRIGGERsample
4684  VBuffMA = numpy.roll(VBuffMA, LShift)
4685  VBuffMB = numpy.roll(VBuffMB, LShift)
4686  VBuffMC = numpy.roll(VBuffMC, LShift)
4687  VBuffMD = numpy.roll(VBuffMD, LShift)
4688  IBuffA = numpy.roll(IBuffA, LShift)
4689  IBuffB = numpy.roll(IBuffB, LShift)
4690  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4691  if ChopTrig.get() == 1:
4692  ReInterploateTrigger(VBuffMA)
4693  if ChopTrig.get() == 2:
4694  ReInterploateTrigger(VBuffMB)
4695  if ChopTrig.get() == 3:
4696  ReInterploateTrigger(VBuffMC)
4697  if ChopTrig.get() == 4:
4698  ReInterploateTrigger(VBuffMD)
4699  else:
4700  if TgInput.get() == 1:
4701  FindTriggerSample(VBuffA)
4702  if TgInput.get() == 2:
4703  FindTriggerSample(IBuffA)
4704  if TgInput.get() == 3:
4705  FindTriggerSample(VBuffB)
4706  if TgInput.get() == 4:
4707  FindTriggerSample(IBuffB)
4708  if TgInput.get() == 5:
4709  FindTriggerSample(VBuffA)
4710  if Is_Triggered == 0: # Trigger event not found for VBuffA so Try VBuffB
4711  FindTriggerSample(VBuffB)
4712  if TgInput.get() == 6:
4713  FindTriggerSample(VBuffA)
4714  TRIGGERsampleAltA = TRIGGERsample
4715  FindTriggerSample(VBuffB)
4716  TRIGGERsampleAltB = TRIGGERsample
4717  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4718  # Average mode 1, add difference / TRACEaverage to array
4719  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
4720  LShift = 0 - TRIGGERsample
4721  if TgInput.get() == 6:
4722  LShift = 0 - TRIGGERsampleAltA
4723  VBuffA = numpy.roll(VBuffA, LShift)
4724  IBuffA = numpy.roll(IBuffA, LShift)
4725  LShift = 0 - TRIGGERsampleAltB
4726  VBuffB = numpy.roll(VBuffB, LShift)
4727  IBuffB = numpy.roll(IBuffB, LShift)
4728  else:
4729  VBuffA = numpy.roll(VBuffA, LShift)
4730  VBuffB = numpy.roll(VBuffB, LShift)
4731  IBuffA = numpy.roll(IBuffA, LShift)
4732  IBuffB = numpy.roll(IBuffB, LShift)
4733  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4734  if UnAvgSav.get() == 1: # copy un averaged trace to buffer
4735  VUnAvgA = VBuffA
4736  VUnAvgB = VBuffB
4737  IUnAvgA = IBuffA
4738  IUnAvgB = IBuffB
4739  try:
4740  if DualMuxMode.get() == 0: # and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
4741  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
4742  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
4743  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4744  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
4745  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
4746  except:
4747  # buffer size mismatch so reset memory buffers
4748  VmemoryA = VBuffA
4749  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4750  VmemoryB = VBuffB
4751  ImemoryA = IBuffA
4752  ImemoryB = IBuffB
4753  if TgInput.get() == 1 or TgInput.get() == 5 or TgInput.get() == 6:
4754  ReInterploateTrigger(VBuffA)
4755  if TgInput.get() == 2:
4756  ReInterploateTrigger(IBuffA)
4757  if TgInput.get() == 3 or TgInput.get() == 5 or TgInput.get() == 6:
4758  ReInterploateTrigger(VBuffB)
4759  if TgInput.get() == 4:
4760  ReInterploateTrigger(IBuffB)
4761 # DC value = average of the data record
4762  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
4763  Endsample = hldn+onescreen # average over only one screen's worth of samples
4764  else:
4765  Endsample = SHOWsamples - 10 # average over all samples
4766  if MeasGateStatus.get() == 1:
4767  if (MeasGateRight-MeasGateLeft) > 0:
4768  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
4769  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
4770  if Endsample <= hldn:
4771  Endsample = hldn + 2
4772 # Calculate scalar values
4773  Cal_trace_scalars(hldn, Endsample)
4774 # Transfer to mux buffers as necessary
4775  if TgInput.get() > 0 and TRACEmodeTime.get() != 1: # and MuxChan > -1
4776  # if triggering left shift all arrays such that trigger point is at index 0
4777  LShift = 0 - TRIGGERsample
4778  VBuffA = numpy.roll(VBuffA, LShift)
4779  VBuffB = numpy.roll(VBuffB, LShift)
4780  IBuffA = numpy.roll(IBuffA, LShift)
4781  IBuffB = numpy.roll(IBuffB, LShift)
4782  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4783  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0 and TRACEmodeTime.get() != 1:
4784  LShift = 0 - TRIGGERsample
4785  VBuffMA = numpy.roll(VBuffMA, LShift)
4786  VBuffMB = numpy.roll(VBuffMB, LShift)
4787  VBuffMC = numpy.roll(VBuffMC, LShift)
4788  VBuffMD = numpy.roll(VBuffMD, LShift)
4789  IBuffA = numpy.roll(IBuffA, LShift)
4790  IBuffB = numpy.roll(IBuffB, LShift)
4791  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4792  if ChopMuxMode.get() == 1 and TRACEmodeTime.get() == 1: # also if in chop mode cal avaerage
4793  # Average mode 1, add difference / TRACEaverage to array
4794  try:
4795  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4796  except: # buffer size mismatch so reset memory buffers
4797  VmemoryMuxA = VBuffMA
4798  try:
4799  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4800  except: # buffer size mismatch so reset memory buffers
4801  VmemoryMuxB = VBuffMB
4802  try:
4803  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4804  except: # buffer size mismatch so reset memory buffers
4805  VmemoryMuxC = VBuffMC
4806  try:
4807  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4808  except: # buffer size mismatch so reset memory buffers
4809  VmemoryMuxD = VBuffMD
4810  if MuxChan > -1 and ChopMuxMode.get() == 0: # do this when not in chop mux mode
4811  if Show_CBA.get() == 1 and MuxChan == 0: # Dval0[0] == 0 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4812  DCVMuxA = DCV2
4813  MinVMuxA = MinV2
4814  MaxVMuxA = MaxV2
4815  MidVMuxA = (MaxV2+MinV2)/2.0
4816  PPVMuxA = MaxV2-MinV2
4817  SVMuxA = SV2
4818  VBuffMA = VBuffB
4819  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4820  # Average mode 1, add difference / TRACEaverage to array
4821  try:
4822  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4823  except:
4824  # buffer size mismatch so reset memory buffers
4825  VmemoryMuxA = VBuffMA
4826  if Show_CBB.get() == 1 and MuxChan == 1: # Dval0[0] == 1 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4827  DCVMuxB = DCV2
4828  MinVMuxB = MinV2
4829  MaxVMuxB = MaxV2
4830  MidVMuxB = (MaxV2+MinV2)/2.0
4831  PPVMuxB = MaxV2-MinV2
4832  SVMuxB = SV2
4833  VBuffMB = VBuffB
4834  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4835  # Average mode 1, add difference / TRACEaverage to array
4836  try:
4837  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4838  except:
4839  # buffer size mismatch so reset memory buffers
4840  VmemoryMuxB = VBuffMB
4841  if Show_CBC.get() == 1 and MuxChan == 2: #and Dval0[0] == 0 and Dval1[0] == 1
4842  if DualMuxMode.get() == 1 :
4843  DCVMuxC = DCV1
4844  MinVMuxC = MinV1
4845  MaxVMuxC = MaxV1
4846  MidVMuxC = (MaxV1+MinV1)/2.0
4847  PPVMuxC = MaxV1-MinV1
4848  SVMuxC = SV1
4849  VBuffMC = VBuffA
4850  else:
4851  DCVMuxC = DCV2
4852  MinVMuxC = MinV2
4853  MaxVMuxC = MaxV2
4854  MidVMuxC = (MaxV2+MinV2)/2.0
4855  PPVMuxC = MaxV2-MinV2
4856  SVMuxC = SV2
4857  VBuffMC = VBuffB
4858  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4859  # Average mode 1, add difference / TRACEaverage to array
4860  try:
4861  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4862  except:
4863  # buffer size mismatch so reset memory buffers
4864  VmemoryMuxC = VBuffMC
4865  if Show_CBD.get() == 1 and MuxChan == 3: #and Dval0[0] == 1 and Dval1[0] == 1
4866  if DualMuxMode.get() == 1 :
4867  DCVMuxD = DCV1
4868  MinVMuxD = MinV1
4869  MaxVMuxD = MaxV1
4870  MidVMuxD = (MaxV1+MinV1)/2.0
4871  PPVMuxD = MaxV1-MinV1
4872  SVMuxD = SV1
4873  VBuffMD = VBuffA
4874  else:
4875  DCVMuxD = DCV2
4876  MinVMuxD = MinV2
4877  MaxVMuxD = MaxV2
4878  MidVMuxD = (MaxV2+MinV2)/2.0
4879  PPVMuxD = MaxV2-MinV2
4880  SVMuxD = SV2
4881  VBuffMD = VBuffB
4882  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4883  # Average mode 1, add difference / TRACEaverage to array
4884  try:
4885  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4886  except:
4887  # buffer size mismatch so reset memory buffers
4888  VmemoryMuxD = VBuffMD
4889  # update screens
4890  if TimeDisp.get() > 0:
4891  # Check if in non functional state of 2X samplerate and 3 or more traces and not enabled AWGSync
4892  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
4893  if NumTraces > 2 and AWGSync.get() == 0 and Two_X_Sample.get() == 1:
4894  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
4895  BStop()
4896  # return
4897  UpdateTimeAll() # Update Data, trace and time screen
4898  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4899  UpdateXYAll() # Update Data, trace and XY screen
4900  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
4901  BStop() #
4902  SingleShot.set(0)
4903  if ManualTrigger.get() == 1: # Manual trigger is on
4904  BStop() #
4905  if MeasureStatus.get() > 0:
4907 #
4908 # Calculate waveform scalar values
4909 def Cal_trace_scalars(SampleStart, SampleEnd):
4910  global VBuffA, VBuffB, IBuffA, IBuffB
4911  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4912  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4913  global SV1, SI1, SV2, SI2, SVA_B
4914 
4915  DCV1 = numpy.mean(VBuffA[SampleStart:SampleEnd])
4916  DCV2 = numpy.mean(VBuffB[SampleStart:SampleEnd])
4917  DCI1 = numpy.mean(IBuffA[SampleStart:SampleEnd])
4918  DCI2 = numpy.mean(IBuffB[SampleStart:SampleEnd])
4919 # find min and max values
4920  MinV1 = numpy.amin(VBuffA[SampleStart:SampleEnd])
4921  MaxV1 = numpy.amax(VBuffA[SampleStart:SampleEnd])
4922  MinV2 = numpy.amin(VBuffB[SampleStart:SampleEnd])
4923  MaxV2 = numpy.amax(VBuffB[SampleStart:SampleEnd])
4924  MinI1 = numpy.amin(IBuffA[SampleStart:SampleEnd])
4925  MaxI1 = numpy.amax(IBuffA[SampleStart:SampleEnd])
4926  MinI2 = numpy.amin(IBuffB[SampleStart:SampleEnd])
4927  MaxI2 = numpy.amax(IBuffB[SampleStart:SampleEnd])
4928 # RMS value = square root of average of the data record squared
4929  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd])))
4930  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[SampleStart:SampleEnd])))
4931  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[SampleStart:SampleEnd])))
4932  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[SampleStart:SampleEnd])))
4933  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[SampleStart:SampleEnd]-VBuffB[SampleStart:SampleEnd])))
4934 #
4935 # Function to calculate relative phase angle between two sine waves of the same frequency
4936 # Removes any DC content
4938  global DCV1, DCV2, VBuffA, VBuffB
4939 
4940  sum1 = 0.0
4941  sum2 = 0.0
4942  sum12 = 0.0
4943  i = 0
4944  n = len(VBuffA)
4945  while i < n:
4946  sum1 += (VBuffA[i]-DCV1)*(VBuffA[i]-DCV1)
4947  sum2 += (VBuffB[i]-DCV2)*(VBuffB[i]-DCV2)
4948  sum12 += (VBuffA[i]-DCV1)*(VBuffB[i]-DCV2)
4949  i += 1
4950  return math.acos(sum12/math.sqrt(sum1*sum2))*180.0/numpy.pi
4951 #
4952 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
4953 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
4954 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
4955 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
4956 
4957 
4959 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
4960  global SAMPLErate, Two_X_Sample
4961 
4962  OutBuff = []
4963  n = len(InBuff)
4964  if Two_X_Sample.get() == 0:
4965  Delta = 1.0/SAMPLErate
4966  else: # adjust for sligh difference in 2X sample mode?
4967  Delta = 0.88/SAMPLErate
4968  TC = TC1 * 1.0E-6
4969  Alpha = TC / (TC + Delta)
4970  OutBuff.append(0.0) # initialize first output sample
4971  i = 1
4972  while i < n:
4973  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
4974  i += 1
4975  OutBuff = numpy.array(OutBuff)
4976  OutBuff = InBuff + (OutBuff * Gain)
4977  return OutBuff
4978 
4980 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
4981  global SAMPLErate
4982 
4983  OutBuff = []
4984  n = len(InBuff)
4985  Delta = 1.0/SAMPLErate
4986  TC = TC1 * 1.0E-6
4987  Alpha = Delta / (TC + Delta)
4988  i = 1
4989  OutBuff.append(Alpha*InBuff[0])
4990  while i < n:
4991  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
4992  i += 1
4993  OutBuff = numpy.array(OutBuff)
4994  OutBuff = (OutBuff * Gain)
4995  return OutBuff
4996 
5000 def shift_buffer(arr, num, fill_value=numpy.nan):
5001  result = numpy.empty_like(arr)
5002  if num > 0:
5003  result[:num] = fill_value
5004  result[num:] = arr[:-num]
5005  elif num < 0:
5006  result[num:] = fill_value
5007  result[:num] = arr[-num:]
5008  else:
5009  result[:] = arr
5010  return result
5011 
5012 
5015  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
5016  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
5017  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
5018  global NSteps, LoopNum, FSweepMode, FStep, FBins
5019  global StartFreqEntry, StopFreqEntry, HoldOffentry
5020  global session, CHA, CHB, devx, MaxSamples, discontloop
5021  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
5022  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
5023  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
5024  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
5025  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
5026  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
5027  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
5028  global BDSweepFile, FileSweepFreq, FileSweepAmpl
5029  global PIO_0, PIO_1, PIO_2, PIO_3
5030  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
5031  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
5032  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5033  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
5034  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
5035 
5036  HalfSAMPLErate = SAMPLErate/2
5037  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
5038  try:
5039  InOffA = float(eval(CHAVOffsetEntry.get()))
5040  except:
5041  CHAVOffsetEntry.delete(0,END)
5042  CHAVOffsetEntry.insert(0, InOffA)
5043  try:
5044  InGainA = float(eval(CHAVGainEntry.get()))
5045  except:
5046  CHAVGainEntry.delete(0,END)
5047  CHAVGainEntry.insert(0, InGainA)
5048  try:
5049  InOffB = float(eval(CHBVOffsetEntry.get()))
5050  except:
5051  CHBVOffsetEntry.delete(0,END)
5052  CHBVOffsetEntry.insert(0, InOffB)
5053  try:
5054  InGainB = float(eval(CHBVGainEntry.get()))
5055  except:
5056  CHBVGainEntry.delete(0,END)
5057  CHBVGainEntry.insert(0, InGainB)
5058  try:
5059  HoldOff = float(eval(HoldOffentry.get()))
5060  if HoldOff < 0:
5061  HoldOff = 0
5062  HoldOffentry.delete(0,END)
5063  HoldOffentry.insert(0, HoldOff)
5064  except:
5065  HoldOffentry.delete(0,END)
5066  HoldOffentry.insert(0, HoldOff)
5067  #
5068  INITIALIZEstart()
5069  # Starting acquisition This is a HACK to get around non-continous AWG mode!
5070  # restart AWGs if indicated
5071  if BodeDisp.get() == 0: # make new noise waveforms each sweep
5072  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
5073  AWGAMakeUUNoise()
5074  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
5075  AWGAMakeUGNoise()
5076  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
5077  AWGBMakeUUNoise()
5078  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
5079  AWGBMakeUGNoise()
5080  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
5081  if BDSweepFile.get() == 0:
5082  if LoopNum.get() <= len(FStep):
5083  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
5084  else:
5085  FregPoint = FBins[FStep[0]]
5086  else:
5087  if LoopNum.get() <= len(FileSweepFreq): #
5088  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
5089  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
5090  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
5091  else:
5092  FregPoint = FBins[FileSweepFreq[0]]
5093  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
5094  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
5095  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
5096  if FSweepMode.get() == 1: # set new CH-A amplitude
5097  AWGAAmplEntry.delete(0,END)
5098  AWGAAmplEntry.insert(4, VMin)
5099  AWGAOffsetEntry.delete(0,END)
5100  AWGAOffsetEntry.insert(4, VMax)
5101  if FSweepMode.get() == 2: # set new CH-B amplitude
5102  AWGBAmplEntry.delete(0,END)
5103  AWGBAmplEntry.insert(4, VMin)
5104  AWGBOffsetEntry.delete(0,END)
5105  AWGBOffsetEntry.insert(4, VMax)
5106  if FSweepMode.get() == 1: # set new CH-A frequency
5107  AWGAFreqEntry.delete(0,END)
5108  AWGAFreqEntry.insert(4, FregPoint)
5110  if FSweepMode.get() == 2: # set new CH-B frequency
5111  AWGBFreqEntry.delete(0,END)
5112  AWGBFreqEntry.insert(4, FregPoint)
5114  if FSweepMode.get() == 3: # set new MiniGen frequency
5115  MinigenFout.delete(0,END)
5116  MinigenFout.insert(4, FregPoint)
5117  BSendMG()
5118  if AWGSync.get() > 0:
5119  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5120  if Two_X_Sample.get() == 1:
5121  AWGBIOMode.set(1)
5122  AWGBMode.set(0)
5123  else:
5124  AWGBMode.set(2)
5125  # BAWGEnab()
5126 #
5127  hldn = int(HoldOff * 100 )
5128  if hldn > MaxSamples-SMPfft:
5129  hldn = MaxSamples-SMPfft
5130  HoldOffentry.delete(0,END)
5131  HoldOffentry.insert(0, hldn/100)
5132  if hldn < 128:
5133  hldn = 128
5134  SHOWsamples = SMPfft + hldn # get holf off extra samples
5135  if BodeDisp.get() > 0: # check if doing Bode Plot
5136  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
5137  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5138  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5139  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5140  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
5141  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5142  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5143  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5144  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
5145  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5146  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5147  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5148  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
5149  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5150  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5151  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5152  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
5153  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5154  if Two_X_Sample.get() == 1:
5155  AWGBIOMode.set(1)
5156  AWGBMode.set(0)
5157  else:
5158  AWGBMode.set(2)
5159  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
5160  if discontloop > 0:
5161  session.flush()
5162  else:
5163  discontloop = 1
5164  BAWGEnab()
5165  try:
5166  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5167  except:
5168  donothing()
5169  # waite to finish then return to open termination
5170  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5171  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5172  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5173  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5174  else: # running in continuous mode
5175  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
5176  #
5177  else:
5178  if session.continuous:
5179  ADsignal1 = devx.read(SHOWsamples, -1, True)
5180  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5181  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5182  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5183  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5184  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5185  FFTBuffA = [] # Clear the FFTBuff array for trace A
5186  FFTBuffB = [] # Clear the FFTBuff array for trace B
5187  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
5188  index = hldn # skip first hldn samples
5189  if SHOWsamples != len(ADsignal1):
5190  SHOWsamples = len(ADsignal1)
5191  while index < SHOWsamples:
5192  if Two_X_Sample.get() == 1:
5193  if ADC_Mux_Mode.get() == 0: # VA and VB
5194  FFTBuffA.append(ADsignal1[index][0][0])
5195  FFTBuffA.append(ADsignal1[index][1][1])
5196  FFTBuffB.append(ADsignal1[index][0][1])
5197  FFTBuffB.append(ADsignal1[index][1][0])
5198  else:
5199  VAdata = ADsignal1[index][0][0]
5200  FFTBuffA.append(VAdata)
5201  VBdata = ADsignal1[index][1][0]
5202  FFTBuffB.append(VBdata)
5203  if VAdata > 5.0 or VAdata < 0.0:
5204  OverRangeFlagA = 1
5205 
5206  if VBdata > 5.0 or VBdata < 0.0:
5207  OverRangeFlagB = 1
5208  index = index + 1
5209 
5210  FFTBuffA = numpy.array(FFTBuffA)
5211  FFTBuffB = numpy.array(FFTBuffB)
5212  FFTBuffA = (FFTBuffA - InOffA) * InGainA
5213  FFTBuffB = (FFTBuffB - InOffB) * InGainB
5214  DCA = numpy.average(FFTBuffA)
5215  DCB = numpy.average(FFTBuffB)
5216  if CutDC.get() == 1:
5217  FFTBuffA = FFTBuffA - DCA
5218  FFTBuffB = FFTBuffB - DCB
5219 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5220  if CHA_RC_HP.get() == 1:
5221  try:
5222  TC1A = float(cha_TC1Entry.get())
5223  if TC1A < 0:
5224  TC1A = 0
5225  cha_TC1Entry.delete(0,END)
5226  cha_TC1Entry.insert(0, TC1A)
5227  except:
5228  TC1A = CHA_TC1.get()
5229  try:
5230  TC2A = float(cha_TC2Entry.get())
5231  if TC2A < 0:
5232  TC2A = 0
5233  cha_TC2Entry.delete(0,END)
5234  cha_TC2Entry.insert(0, TC2A)
5235  except:
5236  TC2A = CHA_TC2.get()
5237  #
5238  try:
5239  Gain1A = float(cha_A1Entry.get())
5240  except:
5241  Gain1A = CHA_A1.get()
5242  try:
5243  Gain2A = float(cha_A2Entry.get())
5244  except:
5245  Gain2A = CHA_A2.get()
5246  #
5247  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
5248  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
5249  if CHB_RC_HP.get() == 1:
5250  try:
5251  TC1B = float(chb_TC1Entry.get())
5252  if TC1B < 0:
5253  TC1B = 0
5254  chb_TC1Entry.delete(0, END)
5255  chb_TC1Entry.insert(0, TC1B)
5256  except:
5257  TC1B = CHB_TC1.get()
5258  try:
5259  TC2B = float(chb_TC2Entry.get())
5260  if TC2B < 0:
5261  TC2B = 0
5262  chb_TC2Entry.delete(0, END)
5263  chb_TC2Entry.insert(0, TC2B)
5264  except:
5265  TC2B = CHB_TC2.get()
5266  #
5267  try:
5268  Gain1B = float(chb_A1Entry.get())
5269  except:
5270  Gain1B = CHB_A1.get()
5271  try:
5272  Gain2B = float(chb_A2Entry.get())
5273  except:
5274  Gain2B = CHB_A2.get()
5275  #
5276  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
5277  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
5278 # check if digital filter box checked
5279  if DigFiltA.get() == 1:
5280  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
5281  if DigFiltB.get() == 1:
5282  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
5283  DoFFT()
5284  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
5285  UpdateFreqAll() # Update spectrum Data, trace and screen
5286  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
5287  UpdateIAAll()
5288  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
5289  UpdateBodeAll()
5290  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
5291  UpdateNqPAll()
5292  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
5293  UpdateNiCAll()
5294  if SingleShotSA.get() == 1: # Single shot sweep is on
5295  RUNstatus.set(0)
5296 #
5297  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
5298  LoopNum.set(LoopNum.get() + 1)
5299  if LoopNum.get() > NSteps.get():
5300  if FSweepMode.get() == 1:
5301  AWGAFreqEntry.delete(0,"end")
5302  AWGAFreqEntry.insert(0, Reset_Freq)
5303  if FSweepMode.get() == 2:
5304  AWGBFreqEntry.delete(0,"end")
5305  AWGBFreqEntry.insert(0, Reset_Freq)
5306 #
5307  LoopNum.set(1)
5308  if FSweepCont.get() == 0:
5309  RUNstatus.set(0)
5310 #
5311 
5313  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
5314  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5315  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
5316  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5317  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5318  global VABase, VATop, VBBase, VBTop
5319 
5320  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
5321  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
5322  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
5323  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
5324  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
5325  LowerPeak = 0
5326  UpperPeak = 0
5327  b = 0
5328  while (b < 4999):
5329  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
5330  LowerPeak = b
5331  VABase = HBuffA[1][b]
5332  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
5333  UpperPeak = b
5334  VATop = HBuffA[1][b]
5335  b = b + 1
5336  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
5337  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
5338  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
5339  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
5340  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
5341  LowerPeak = 0
5342  UpperPeak = 0
5343  b = 0
5344  while (b < 4999):
5345  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
5346  LowerPeak = b
5347  VBBase = HBuffB[1][b]
5348  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
5349  UpperPeak = b
5350  VBTop = HBuffB[1][b]
5351  b = b + 1
5352 
5354  global HistAsPercent
5355 
5356  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
5357  HistAsPercent = 1
5358  else:
5359  HistAsPercent = 0
5360 
5361 def FindRisingEdge(Trace1, Trace2):
5362  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
5363  global ETSrecord, DISsamples
5364  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
5365  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
5366  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
5367 
5368  anr1 = bnr1 = 0
5369  anf1 = bnf1 = 1
5370  anr2 = bnr2 = 2
5371  hldn = int(HoldOff * SAMPLErate/1000)
5372  # print(DISsamples, len(Trace1))
5373  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
5374  Trace1 = numpy.roll(Trace1, -LShift)
5375  Trace2 = numpy.roll(Trace2, -LShift)
5376  else:
5377  Trace1 = numpy.roll(Trace1, -hldn)
5378  Trace2 = numpy.roll(Trace2, -hldn)
5379  try:
5380  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
5381  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
5382  except:
5383  MidV1 = (MinV1+MaxV1)/2
5384  MidV2 = (MinV2+MaxV2)/2
5385 # search Trace 1
5386 
5393  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
5394  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
5395  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
5396  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
5397 
5398  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
5399  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
5400 # Catch zero length array?
5401  try:
5402  Dummy_read = Arising[0]
5403  except:
5404  return
5405  if len(Arising) > 0 or len(Afalling) > 0:
5406  if Arising[0] > 0:
5407  try:
5408  anr1 = AIrising[0]
5409  except:
5410  anr1 = 0
5411  try:
5412  anr2 = AIrising[1]
5413  except:
5414  anr2 = SHOWsamples
5415  try:
5416  if AIfalling[0] < AIrising[0]:
5417  anf1 = AIfalling[1]
5418  else:
5419  anf1 = AIfalling[0]
5420  except:
5421  anf1 = 1
5422  else:
5423  try:
5424  anr1 = AIrising[1]
5425  except:
5426  anr1 = 0
5427  try:
5428  anr2 = AIrising[2]
5429  except:
5430  anr2 = SHOWsamples
5431  try:
5432  if AIfalling[1] < AIrising[1]:
5433  anf1 = AIfalling[2]
5434  else:
5435  anf1 = AIfalling[1]
5436  except:
5437  anf1 = 1
5438 # search Trace 2
5439 
5446  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
5447  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
5448  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
5449  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
5450 
5451  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
5452  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
5453 # Catch zero length array?
5454  try:
5455  Dummy_read = Brising[0]
5456  except:
5457  return
5458  if len(Brising) > 0 or len(Bfalling) > 0:
5459  if Brising[0] > 0:
5460  try:
5461  bnr1 = BIrising[0]
5462  except:
5463  bnr1 = 0
5464  try:
5465  bnr2 = BIrising[1]
5466  except:
5467  bnr2 = SHOWsamples
5468  try:
5469  if BIfalling[0] < BIrising[0]:
5470  bnf1 = BIfalling[1]
5471  else:
5472  bnf1 = BIfalling[0]
5473  except:
5474  bnf1 = 1
5475  else:
5476  try:
5477  bnr1 = BIrising[1]
5478  except:
5479  bnr1 = 0
5480  try:
5481  bnr2 = BIrising[2]
5482  except:
5483  bnr2 = SHOWsamples
5484  try:
5485  if BIfalling[1] < BIrising[1]:
5486  bnf1 = BIfalling[2]
5487  else:
5488  bnf1 = BIfalling[1]
5489  except:
5490  bnf1 = 1
5491  #
5492  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
5493  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
5494  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
5495  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
5496  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
5497  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
5498 #
5499  if bnr1 > anr1:
5500  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
5501  else:
5502  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
5503  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
5504  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
5505  try:
5506  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
5507  except:
5508  CHABphase = 0.0
5509  if CHABphase < 0.0:
5510  CHABphase = CHABphase + 360.0
5511 
5513  global DX, TRIGGERsample, TRIGGERlevel
5514 
5515  DX = 0
5516  n = TRIGGERsample
5517  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
5518  if DY != 0.0:
5519  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
5520  else:
5521  DX = 0
5522 
5523 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
5524  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
5525  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
5526  global Trigger_LPF_length, LPFTrigger
5527 
5528  # Set the TRACEsize variable
5529  TRACEsize = SHOWsamples # Set the trace length
5530  DX = 0
5531  Is_Triggered = 0
5532  if LPFTrigger.get() > 0:
5533  TFiltCoef = [] # empty coef array
5534  for n in range(Trigger_LPF_length.get()):
5535  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
5536  TFiltCoef = numpy.array(TFiltCoef)
5537  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
5538 
5539  if len(TrgBuff) == 0:
5540  return
5541  try:
5542  TrgMin = numpy.amin(TrgBuff)
5543  except:
5544  TrgMin = 0.0
5545  try:
5546  TrgMax = numpy.amax(TrgBuff)
5547  except:
5548  TrgMax = 0.0
5549 # Find trigger sample
5550  try:
5551  if AutoLevel.get() == 1:
5552  TRIGGERlevel = (TrgMin + TrgMax)/2
5553  TRIGGERentry.delete(0,"end")
5554  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
5555  else:
5556  TRIGGERlevel = eval(TRIGGERentry.get())
5557  except:
5558  TRIGGERentry.delete(0,END)
5559  TRIGGERentry.insert(0, TRIGGERlevel)
5560 # Start from first sample after HoldOff
5561  try:
5562  HoldOff = float(eval(HoldOffentry.get()))
5563  if HoldOff < 0:
5564  HoldOff = 0
5565  HoldOffentry.delete(0,END)
5566  HoldOffentry.insert(0, HoldOff)
5567  except:
5568  HoldOffentry.delete(0,END)
5569  HoldOffentry.insert(0, HoldOff)
5570 # slide trace left right by HozPoss
5571  try:
5572  HozPoss = float(eval(HozPossentry.get()))
5573  except:
5574  HozPossentry.delete(0,END)
5575  HozPossentry.insert(0, HozPoss)
5576 
5577  hldn = int(HoldOff * SAMPLErate/1000)
5578  hozpos = int(HozPoss * SAMPLErate/1000)
5579  if hozpos >= 0:
5580  TRIGGERsample = hldn
5581  else:
5582  TRIGGERsample = abs(hozpos)
5583 #
5584  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
5585  DX = 0
5586  n = TRIGGERsample
5587  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
5588  if TRIGGERlevel2 < TrgMin:
5589  TRIGGERlevel2 = TrgMin
5590  if TRIGGERlevel2 > TrgMax:
5591  TRIGGERlevel2 = TrgMax
5592  ChInput = TrgBuff[int(n)]
5593  Prev = ChInput
5594  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
5595  n = n + 1
5596  ChInput = TrgBuff[int(n)]
5597  while (ChInput <= TRIGGERlevel) and n < Nmax:
5598  Prev = ChInput
5599  n = n + 1
5600  ChInput = TrgBuff[int(n)]
5601  DY = ChInput - Prev
5602  if DY != 0.0:
5603  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
5604  else:
5605  DX = 0
5606  if TgEdge.get() == 1:
5607  TRIGGERlevel2 = 1.01 * TRIGGERlevel
5608  if TRIGGERlevel2 < TrgMin:
5609  TRIGGERlevel2 = TrgMin
5610  if TRIGGERlevel2 > TrgMax:
5611  TRIGGERlevel2 = TrgMax
5612  ChInput = TrgBuff[int(n)]
5613  Prev = ChInput
5614  while (ChInput <= TRIGGERlevel2) and n < Nmax:
5615  n = n + 1
5616  ChInput = TrgBuff[int(n)]
5617  while (ChInput >= TRIGGERlevel) and n < Nmax:
5618  Prev = ChInput
5619  n = n + 1
5620  ChInput = TrgBuff[int(n)]
5621  DY = Prev - ChInput
5622  try:
5623  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
5624  except:
5625  DX = 0
5626 
5627 # check to insure trigger point is in bounds
5628  if n < Nmax:
5629  TRIGGERsample = n - 1
5630  Is_Triggered = 1
5631  elif n > Nmax: # Didn't find edge in first 2/3 of data set
5632  TRIGGERsample = 1 + hldn # reset to begining
5633  Is_Triggered = 0
5634  if DX > 1:
5635  DX = 1 # never more than 100% of a sample period
5636  elif DX < 0:
5637  DX = 0 # never less than 0% of a sample period
5638  if math.isnan(DX):
5639  DX = 0
5640  TRIGGERsample = TRIGGERsample + hozpos
5641 
5643  global win2, DigScreenStatus
5644 
5645  DigScreenStatus.set(0)
5646  win2.destroy()
5647 #
5648 def sel(): # change Digital I/O and update screen color readback
5649  global devx, DevID
5650  global D0, D1, D2, D3, D4, D5, D6, D7
5651  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5652  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5653  # sending 0x50 = set to 0, 0x51 = set to 1
5654  if D0.get() > 0:
5655  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
5656  if D0.get() == 0x50:
5657  digin0.configure(text="Low", background="#00ff00")
5658  else:
5659  digin0.configure(text="Hi", background="#ff0000")
5660  else:
5661  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
5662  if Dval[0] == 0:
5663  digin0.configure(text="Low", background="#00ff00")
5664  else:
5665  digin0.configure(text="Hi", background="#ff0000")
5666  if D1.get() > 0:
5667  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
5668  if D1.get() == 0x50:
5669  digin1.configure(text="Low", background="#00ff00")
5670  else:
5671  digin1.configure(text="Hi", background="#ff0000")
5672  else:
5673  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
5674  if Dval[0] == 0:
5675  digin1.configure(text="Low", background="#00ff00")
5676  else:
5677  digin1.configure(text="Hi", background="#ff0000")
5678  if D2.get() > 0:
5679  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
5680  if D2.get() == 0x50:
5681  digin2.configure(text="Low", background="#00ff00")
5682  else:
5683  digin2.configure(text="Hi", background="#ff0000")
5684  else:
5685  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
5686  if Dval[0] == 0:
5687  digin2.configure(text="Low", background="#00ff00")
5688  else:
5689  digin2.configure(text="Hi", background="#ff0000")
5690  if D3.get() > 0:
5691  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
5692  if D3.get() == 0x50:
5693  digin3.configure(text="Low", background="#00ff00")
5694  else:
5695  digin3.configure(text="Hi", background="#ff0000")
5696  else:
5697  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
5698  if Dval[0] == 0:
5699  digin3.configure(text="Low", background="#00ff00")
5700  else:
5701  digin3.configure(text="Hi", background="#ff0000")
5702  if D4.get() > 0:
5703  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
5704  if D4.get() == 0x50:
5705  digin4.configure(text="Low", background="#00ff00")
5706  else:
5707  digin4.configure(text="Hi", background="#ff0000")
5708  else:
5709  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
5710  if Dval[0] == 0:
5711  digin4.configure(text="Low", background="#00ff00")
5712  else:
5713  digin4.configure(text="Hi", background="#ff0000")
5714  if D5.get() > 0:
5715  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
5716  if D5.get() == 0x50:
5717  digin5.configure(text="Low", background="#00ff00")
5718  else:
5719  digin5.configure(text="Hi", background="#ff0000")
5720  else:
5721  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
5722  if Dval[0] == 0:
5723  digin5.configure(text="Low", background="#00ff00")
5724  else:
5725  digin5.configure(text="Hi", background="#ff0000")
5726  if D6.get() > 0:
5727  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
5728  if D6.get() == 0x50:
5729  digin6.configure(text="Low", background="#00ff00")
5730  else:
5731  digin6.configure(text="Hi", background="#ff0000")
5732  else:
5733  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
5734  if Dval[0] == 0:
5735  digin6.configure(text="Low", background="#00ff00")
5736  else:
5737  digin6.configure(text="Hi", background="#ff0000")
5738  if D7.get() > 0:
5739  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
5740  if D7.get() == 0x50:
5741  digin7.configure(text="Low", background="#00ff00")
5742  else:
5743  digin7.configure(text="Hi", background="#ff0000")
5744  else:
5745  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
5746  if Dval[0] == 0:
5747  digin7.configure(text="Low", background="#00ff00")
5748  else:
5749  digin7.configure(text="Hi", background="#ff0000")
5750 
5751 
5753  global D0, D1, D2, D3, D4, D5, D6, D7
5754  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5755  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5756  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
5757  # setup Dig output window
5758  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5759  DigScreenStatus.set(1)
5760  win2 = Toplevel()
5761  win2.title("Dig Out")
5762  win2.resizable(FALSE,FALSE)
5763  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
5764  drb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
5765  drb1.grid(row=2, column=0, sticky=W)
5766  drb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
5767  drb0z.grid(row=2, column=1, sticky=W)
5768  drb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
5769  drb2.grid(row=2, column=2, sticky=W)
5770  digin0 = Label(win2, text="Low", background = "#00ff00")
5771  digin0.grid(row=2, column=3, sticky=W)
5772  drb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
5773  drb3.grid(row=3, column=0, sticky=W)
5774  drb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
5775  drb3z.grid(row=3, column=1, sticky=W)
5776  drb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
5777  drb4.grid(row=3, column=2, sticky=W)
5778  digin1 = Label(win2, text="Low", background = "#00ff00")
5779  digin1.grid(row=3, column=3, sticky=W)
5780  drb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
5781  drb5.grid(row=4, column=0, sticky=W)
5782  drb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
5783  drb5z.grid(row=4, column=1, sticky=W)
5784  drb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
5785  drb6.grid(row=4, column=2, sticky=W)
5786  digin2 = Label(win2, text="Low", background = "#00ff00")
5787  digin2.grid(row=4, column=3, sticky=W)
5788  drb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
5789  drb7.grid(row=5, column=0, sticky=W)
5790  drb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
5791  drb7z.grid(row=5, column=1, sticky=W)
5792  drb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
5793  drb8.grid(row=5, column=2, sticky=W)
5794  digin3 = Label(win2, text="Low", background = "#00ff00")
5795  digin3.grid(row=5, column=3, sticky=W)
5796  drb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
5797  drb9.grid(row=6, column=0, sticky=W)
5798  drb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
5799  drb9z.grid(row=6, column=1, sticky=W)
5800  drb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
5801  drb10.grid(row=6, column=2, sticky=W)
5802  digin4 = Label(win2, text="Low", background = "#00ff00")
5803  digin4.grid(row=6, column=3, sticky=W)
5804  drb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
5805  drb11.grid(row=7, column=0, sticky=W)
5806  drb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
5807  drb11z.grid(row=7, column=1, sticky=W)
5808  drb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
5809  drb12.grid(row=7, column=2, sticky=W)
5810  digin5 = Label(win2, text="Low", background = "#00ff00")
5811  digin5.grid(row=7, column=3, sticky=W)
5812  drb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
5813  drb13.grid(row=8, column=0, sticky=W)
5814  drb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
5815  drb13z.grid(row=8, column=1, sticky=W)
5816  drb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
5817  drb13.grid(row=8, column=2, sticky=W)
5818  digin6 = Label(win2, text="Low", background = "#00ff00")
5819  digin6.grid(row=8, column=3, sticky=W)
5820  drb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
5821  drb14.grid(row=9, column=0, sticky=W)
5822  drb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
5823  drb14z.grid(row=9, column=1, sticky=W)
5824  drb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
5825  drb15.grid(row=9, column=2, sticky=W)
5826  digin7 = Label(win2, text="Low", background = "#00ff00")
5827  digin7.grid(row=9, column=3, sticky=W)
5828 
5829  digdismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
5830  digdismissbutton.grid(row=10, column=0, sticky=W)
5831 
5833  global win1, DacScreenStatus
5834 
5835  DacScreenStatus.set(0)
5836  win1.destroy()
5837 
5838 def sel0(temp):
5839  global devx, DevID
5840  global PIO_0, PIO_4
5841  global DAC0
5842  # sending 0x50 = set to 0, 0x51 = set to 1
5843  if DAC0.get() == 1:
5844  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5845  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
5846  elif DAC0.get() == 4:
5847  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5848  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5849  elif DAC0.get() == 2:
5850  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5851  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5852  elif DAC0.get() == 3:
5853  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
5854  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5855  elif DAC0.get() == 5:
5856  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5857  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5858  elif DAC0.get() == 7:
5859  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5860  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5861  elif DAC0.get() == 8:
5862  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
5863  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5864  elif DAC0.get() == 6:
5865  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5866  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5867  elif DAC0.get() == 9:
5868  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5869  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
5870 
5871 def sel1(temp):
5872  global devx, DevID
5873  global PIO_1, PIO_5
5874  global DAC1
5875  # sending 0x50 = set to 0, 0x51 = set to 1
5876  if DAC1.get() == 1:
5877  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5878  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
5879  elif DAC1.get() == 4:
5880  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5881  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5882  elif DAC1.get() == 2:
5883  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5884  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5885  elif DAC1.get() == 3:
5886  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5887  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5888  elif DAC1.get() == 5:
5889  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5890  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5891  elif DAC1.get() == 7:
5892  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5893  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5894  elif DAC1.get() == 8:
5895  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
5896  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5897  elif DAC1.get() == 6:
5898  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5899  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5900  elif DAC1.get() == 9:
5901  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5902  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
5903 
5904 def sel2(temp):
5905  global devx, DevID
5906  global PIO_2, PIO_6
5907  global DAC2
5908  # sending 0x50 = set to 0, 0x51 = set to 1
5909  if DAC2.get() == 1:
5910  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5911  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
5912  elif DAC2.get() == 4:
5913  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5914  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5915  elif DAC2.get() == 2:
5916  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5917  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5918  elif DAC2.get() == 3:
5919  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5920  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5921  elif DAC2.get() == 5:
5922  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5923  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5924  elif DAC2.get() == 7:
5925  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5926  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5927  elif DAC2.get() == 8:
5928  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
5929  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5930  elif DAC2.get() == 6:
5931  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5932  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5933  elif DAC2.get() == 9:
5934  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5935  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
5936 
5937 def sel3(temp):
5938  global devx, DevID
5939  global PIO_3, PIO_7
5940  global DAC3
5941  # sending 0x50 = set to 0, 0x51 = set to 1
5942  if DAC3.get() == 1:
5943  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5944  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
5945  elif DAC3.get() == 4:
5946  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5947  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5948  elif DAC3.get() == 2:
5949  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5950  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5951  elif DAC3.get() == 3:
5952  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5953  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5954  elif DAC3.get() == 5:
5955  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5956  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5957  elif DAC3.get() == 7:
5958  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5959  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5960  elif DAC3.get() == 8:
5961  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
5962  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5963  elif DAC3.get() == 6:
5964  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5965  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5966  elif DAC3.get() == 9:
5967  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5968  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
5969 
5971  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
5972  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
5973  # setup Dig output window
5974  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5975  DacScreenStatus.set(1)
5976  win1 = Toplevel()
5977  win1.title("DAC Out "+ SWRev + RevDate)
5978  win1.resizable(FALSE,FALSE)
5979  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
5980  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
5981  DAC0.grid(row=0, column=0, sticky=W)
5982  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
5983  DAC1.grid(row=0, column=1, sticky=W)
5984  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
5985  DAC2.grid(row=0, column=2, sticky=W)
5986  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
5987  DAC3.grid(row=0, column=3, sticky=W)
5988 
5989  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
5990  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
5991 
5993 
5994  MakeTimeTrace() # Update the traces
5995  UpdateTimeScreen() # Update the screen
5996 
5998 
5999  MakeTimeTrace() # Update traces
6000  UpdateTimeScreen() # Update the screen
6001 
6003 
6004  MakeTimeScreen() # Update the screen
6005  root.update() # Activate updated screens
6006 
6008 
6009  MakeXYTrace() # Update the traces
6010  UpdateXYScreen() # Update the screen
6011 
6013 
6014  MakeXYTrace() # Update traces
6015  UpdateXYScreen() # Update the screen
6016 
6018 
6019  MakeXYScreen() # Update the screen
6020  root.update() # Activate updated screens
6021 
6023  global VBuffA, VBuffB, IBuffA, IBuffB
6024  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
6025  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
6026  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
6027  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
6028  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
6029  global D0line, D1line, D2line, D3line
6030  global FFTBuffA, FFTBuffB, FFTwindowshape
6031  global AWGAwaveform, AWGBwaveform
6032  global T1Vline, T2Vline, T1Iline, T2Iline
6033  global TMAVline, TMBVline, TMCVline, TMDVline
6034  global Tmathline, TMXline, TMYline
6035  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
6036  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
6037  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
6038  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
6039  global SHOWsamples, ZOHold, AWGBMode
6040  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
6041  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
6042  global Show_MathX, Show_MathY
6043  global TRACES, TRACESread, RUNstatus
6044  global AutoCenterA, AutoCenterB
6045  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
6046  global TMpdiv # Array with time / div values in ms
6047  global TMsb # Time per div spin box variable
6048  global TIMEdiv # current spin box value
6049  global SAMPLErate, SCstart, Two_X_Sample, DISsamples, First_Slow_sweep
6050  global TRIGGERsample, TRACEsize, DX, TRIGGERsampleAltA, TRIGGERsampleAltB
6051  global TRIGGERlevel, TRIGGERentry, AutoLevel
6052  global InOffA, InGainA, InOffB, InGainB
6053  global CurOffA, CurOffB, CurGainA, CurGainB
6054  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6055  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6056  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6057  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6058  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6059  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6060  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6061  global HozPoss, HozPossentry
6062 
6063  # Set the TRACEsize variable
6064  if len(VBuffA) < 100 and MuxScreenStatus.get() == 0:
6065  return
6066  TRACEsize = SHOWsamples # Set the trace length
6067  SCstart = 0
6068  ylo = 0.0
6069  xlo = 0.0
6070  Ymin = Y0T # Minimum position of time grid (top)
6071  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6072  Xmin = X0L # Minimum position of time grid (left)
6073  Xmax = X0L + GRW # Maximum position of time grid (right)
6074 
6075  # prevent divide by zero error
6076  if TIMEdiv < 0.0002:
6077  TIMEdiv = 0.01
6078  # Check for Auto Centering
6079  if AutoCenterA.get() > 0:
6080  CHAOffset = DCV1
6081  CHAVPosEntry.delete(0,END)
6082  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
6083  if AutoCenterB.get() > 0:
6084  CHBOffset = DCV2
6085  CHBVPosEntry.delete(0,END)
6086  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
6087  # get the vertical ranges
6088  try:
6089  CH1pdvRange = float(eval(CHAsb.get()))
6090  except:
6091  CHAsb.delete(0,END)
6092  CHAsb.insert(0, CH1pdvRange)
6093  try:
6094  CH2pdvRange = float(eval(CHBsb.get()))
6095  except:
6096  CHBsb.delete(0,END)
6097  CHBsb.insert(0, CH2pdvRange)
6098  try:
6099  CH1IpdvRange = float(eval(CHAIsb.get()))
6100  except:
6101  CHAIsb.delete(0,END)
6102  CHAIsb.insert(0, CH1IpdvRange)
6103  try:
6104  CH2IpdvRange = float(eval(CHBIsb.get()))
6105  except:
6106  CHBIsb.delete(0,END)
6107  CHBIsb.insert(0, CH2IpdvRange)
6108  # get the vertical offsets
6109  try:
6110  CHAOffset = float(eval(CHAVPosEntry.get()))
6111  except:
6112  CHAVPosEntry.delete(0,END)
6113  CHAVPosEntry.insert(0, CHAOffset)
6114  try:
6115  CHAIOffset = float(eval(CHAIPosEntry.get()))
6116  except:
6117  CHAIPosEntry.delete(0,END)
6118  CHAIPosEntry.insert(0, CHAIOffset)
6119  try:
6120  CHBOffset = float(eval(CHBVPosEntry.get()))
6121  except:
6122  CHBVPosEntry.delete(0,END)
6123  CHBVPosEntry.insert(0, CHBOffset)
6124  try:
6125  CHBIOffset = float(eval(CHBIPosEntry.get()))
6126  except:
6127  CHBIPosEntry.delete(0,END)
6128  CHBIPosEntry.insert(0, CHBIOffset)
6129  # prevent divide by zero error
6130  if CH1pdvRange < 0.001:
6131  CH1pdvRange = 0.001
6132  if CH2pdvRange < 0.001:
6133  CH2pdvRange = 0.001
6134  if CH1IpdvRange < 0.1:
6135  CH1IpdvRange = 0.1
6136  if CH2IpdvRange < 0.1:
6137  CH2IpdvRange = 0.1
6138 #
6139  try:
6140  HoldOff = float(eval(HoldOffentry.get()))
6141  if HoldOff < 0:
6142  HoldOff = 0
6143  HoldOffentry.delete(0,END)
6144  HoldOffentry.insert(0, HoldOff)
6145  except:
6146  HoldOffentry.delete(0,END)
6147  HoldOffentry.insert(0, HoldOff)
6148 #
6149  try:
6150  HozPoss = float(eval(HozPossentry.get()))
6151  except:
6152  HozPossentry.delete(0,END)
6153  HozPossentry.insert(0, HozPoss)
6154 #
6155  hldn = int(HoldOff * SAMPLErate/1000 )
6156  hozpos = int(HozPoss * SAMPLErate/1000 )
6157  if hozpos < 0:
6158  hozpos = 0
6159  # drawing the traces
6160  if TRACEsize == 0: # If no trace, skip rest of this routine
6161  T1Vline = [] # Trace line channel A V
6162  T2Vline = [] # Trace line channel B V
6163  T1Iline = []
6164  T2Iline = []
6165  TMAVline = [] # V Trace line Mux channel A
6166  TMBVline = [] # V Trace line Mux channel B
6167  TMCVline = [] # V Trace line Mux channel C
6168  TMDVline = [] # V Trace line Mux channel D
6169  Tmathline = [] # math trce line
6170  return()
6171 
6172  # set and/or corrected for in range
6173  if TgInput.get() > 0 or ChopTrig.get() > 0:
6174  SCmin = int(-1 * TRIGGERsample)
6175  SCmax = int(TRACEsize - TRIGGERsample - 0)
6176  else:
6177  SCmin = 0 # hldn
6178  SCmax = TRACEsize - 1
6179  if SCstart < SCmin: # No reading before start of array
6180  SCstart = SCmin
6181  if SCstart > SCmax: # No reading after end of array
6182  SCstart = SCmax
6183 
6184  # Make Trace lines etc.
6185 
6186  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6187  Yconv2 = float(GRH/10.0) / CH2pdvRange
6188  YIconv1 = float(GRH/10.0) / CH1IpdvRange
6189  YIconv2 = float(GRH/10.0) / CH2IpdvRange
6190  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6191  Xconv2 = float(GRW/10.0) / CH2pdvRange
6192  XIconv1 = float(GRW/10.0) / CH1IpdvRange
6193  XIconv2 = float(GRW/10.0) / CH2IpdvRange
6194  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6195  try:
6196  CHMApdvRange = float(eval(CHB_Asb.get()))
6197  except:
6198  CHB_Asb.delete(0,END)
6199  CHB_Asb.insert(0, CHMApdvRange)
6200  try:
6201  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6202  except:
6203  CHB_Bsb.delete(0,END)
6204  CHB_Bsb.insert(0, CHMBpdvRange)
6205  try:
6206  CHMCpdvRange = float(eval(CHB_Csb.get()))
6207  except:
6208  CHB_Csb.delete(0,END)
6209  CHB_Csb.insert(0, CHMCpdvRange)
6210  try:
6211  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6212  except:
6213  CHB_Dsb.delete(0,END)
6214  CHB_Dsb.insert(0, CHMDpdvRange)
6215  YconvMA = float(GRH/10.0) / CHMApdvRange
6216  YconvMB = float(GRH/10.0) / CHMBpdvRange
6217  YconvMC = float(GRH/10.0) / CHMCpdvRange
6218  YconvMD = float(GRH/10.0) / CHMDpdvRange
6219  try:
6220  CHBAOffset = float(eval(CHB_APosEntry.get()))
6221  except:
6222  CHB_APosEntry.delete(0,END)
6223  CHB_APosEntry.insert(0, CHBAOffset)
6224  try:
6225  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6226  except:
6227  CHB_BPosEntry.delete(0,END)
6228  CHB_BPosEntry.insert(0, CHBBOffset)
6229  try:
6230  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6231  except:
6232  CHB_CPosEntry.delete(0,END)
6233  CHB_CPosEntry.insert(0, CHBCOffset)
6234  try:
6235  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6236  except:
6237  CHB_DPosEntry.delete(0,END)
6238  CHB_DPosEntry.insert(0, CHBDOffset)
6239  if MathAxis == "V-A":
6240  YconvM = Yconv1
6241  CHMOffset = CHAOffset
6242  elif MathAxis == "V-B":
6243  YconvM = Yconv2
6244  CHMOffset = CHBOffset
6245  elif MathAxis == "I-A":
6246  YconvM = YIconv1
6247  CHMOffset = CHAIOffset
6248  elif MathAxis == "I-B":
6249  YconvM = YIconv2
6250  CHMOffset = CHBIOffset
6251  else:
6252  YconvM = Yconv1
6253  CHMOffset = CHAOffset
6254 # include ploting X and Y math formulas vs time
6255  if MathYAxis == "V-A":
6256  YconvMxy = Yconv1
6257  CHMYOffset = CHAOffset
6258  elif MathYAxis == "V-B":
6259  YconvMxy = Yconv2
6260  CHMYOffset = CHBOffset
6261  elif MathYAxis == "I-A":
6262  YconvMxy = YIconv1
6263  CHMYOffset = CHAIOffset
6264  elif MathYAxis == "I-B":
6265  YconvMxy = YIconv2
6266  CHMYOffset = CHBIOffset
6267  else:
6268  YconvMxy = Yconv1
6269  CHMYOffset = CHAOffset
6270 #
6271  if MathXAxis == "V-A":
6272  XconvMxy = Yconv1
6273  CHMXOffset = CHAOffset
6274  elif MathXAxis == "V-B":
6275  XconvMxy = Yconv2
6276  CHMXOffset = CHBOffset
6277  elif MathXAxis == "I-A":
6278  XconvMxy = YIconv1
6279  CHMXOffset = CHAIOffset
6280  elif MathXAxis == "I-B":
6281  XconvMxy = YIconv2
6282  CHMXOffset = CHBIOffset
6283  else:
6284  XconvMxy = Yconv1
6285  CHMXOffset = CHAOffset
6286 #
6287  c1 = GRH / 2.0 + Y0T # fixed correction channel A
6288  c2 = GRH / 2.0 + Y0T # fixed correction channel B
6289 
6290  if First_Slow_sweep == 1:
6291  TRACEsize = len(VBuffA)
6292  DISsamples = GRW
6293  D0line = []
6294  D1line = []
6295  D2line = []
6296  D3line = []
6297  Dconv = float(GRH/10.0) # pixels per Div
6298  else:
6299  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
6300  T1Vline = [] # V Trace line channel A
6301  T2Vline = [] # V Trace line channel B
6302  T1Iline = [] # I Trace line channel A
6303  T2Iline = [] # I Trace line channel B
6304  TMAVline = [] # V Trace line Mux channel A
6305  TMBVline = [] # V Trace line Mux channel B
6306  TMCVline = [] # V Trace line Mux channel C
6307  TMDVline = [] # V Trace line Mux channel D
6308  Tmathline = [] # math trce line
6309  TMXline = [] # X math Trace line
6310  TMYline = [] # Y math Trace line
6311  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
6312  return
6313  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6314  if t < 0:
6315  t = 0
6316  x = 0 # Horizontal screen pixel
6317 #
6318  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6319  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
6320  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6321  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
6322  DvY1 = DvY2 = DiY1 = DiY2 = 0
6323 #
6324  if (DISsamples <= GRW):
6325  Xstep = GRW / DISsamples
6326  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
6327  xa = int((Xstep/-2.5) - (Xstep*DX))
6328  else:
6329  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
6330  x = 0 - int(Xstep*DX)
6331  Tstep = 1
6332  x1 = 0 # x position of trace line
6333  xa1 = 0
6334  y1 = 0.0 # y position of trace line
6335  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6336  ytemp = IBuffA[t]
6337  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6338  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6339  if MuxScreenStatus.get() == 1:
6340  if len(VBuffMA) > 4:
6341  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6342  if len(VBuffMB) > 4:
6343  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6344  if len(VBuffMC) > 4:
6345  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6346  if len(VBuffMD) > 4:
6347  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6348  ytemp = IBuffB[t]
6349  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6350  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
6351  if TgInput.get() == 0:
6352  Xlimit = GRW
6353  else:
6354  Xlimit = GRW+Xstep
6355  while x <= Xlimit:
6356  if t < TRACEsize:
6357  xa1 = xa + X0L
6358  x1 = x + X0L
6359  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6360  ytemp = IBuffA[t]
6361  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6362 
6363  if y1 < Ymin: # clip waveform if going off grid
6364  y1 = Ymin
6365  if y1 > Ymax:
6366  y1 = Ymax
6367  if yi1 < Ymin:
6368  yi1 = Ymin
6369  if yi1 > Ymax:
6370  yi1 = Ymax
6371  if ShowC1_V.get() == 1 :
6372  if ZOHold.get() == 1:
6373  T1Vline.append(int(xa1))
6374  T1Vline.append(int(ypv1))
6375  T1Vline.append(int(xa1))
6376  T1Vline.append(int(y1))
6377  else:
6378  T1Vline.append(int(xa1))
6379  T1Vline.append(int(y1))
6380  DvY1 = ypv1 - y1
6381  ypv1 = y1
6382  if ShowC1_I.get() == 1:
6383  if ZOHold.get() == 1:
6384  T1Iline.append(int(xa1))
6385  T1Iline.append(int(ypi1))
6386  T1Iline.append(int(xa1))
6387  T1Iline.append(int(yi1))
6388  else:
6389  T1Iline.append(int(xa1))
6390  T1Iline.append(int(yi1))
6391  DiY1 = ypi1 - yi1
6392  ypi1 = yi1
6393  if ShowC2_V.get() == 1:
6394  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6395  if y1 < Ymin: # clip waveform if going off grid
6396  y1 = Ymin
6397  if y1 > Ymax:
6398  y1 = Ymax
6399  if ZOHold.get() == 1:
6400  T2Vline.append(int(x1))
6401  T2Vline.append(int(ypv2))
6402  T2Vline.append(int(x1))
6403  T2Vline.append(int(y1))
6404  else:
6405  T2Vline.append(int(x1))
6406  T2Vline.append(int(y1))
6407  DvY2 = ypv2 - y1
6408  ypv2 = y1
6409  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
6410  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6411  if y1 < Ymin: # clip waveform if going off grid
6412  y1 = Ymin
6413  if y1 > Ymax:
6414  y1 = Ymax
6415  if ZOHold.get() == 1:
6416  TMAVline.append(int(x1))
6417  TMAVline.append(int(ypvma))
6418  TMAVline.append(int(x1))
6419  TMAVline.append(int(y1))
6420  else:
6421  TMAVline.append(int(x1))
6422  TMAVline.append(int(y1))
6423  ypvma = y1
6424  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6425  Xfine = MouseX - X0L - x
6426  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
6427  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
6428  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6429  if y1 < Ymin: # clip waveform if going off grid
6430  y1 = Ymin
6431  if y1 > Ymax:
6432  y1 = Ymax
6433  if ZOHold.get() == 1:
6434  TMBVline.append(int(x1))
6435  TMBVline.append(int(ypvmb))
6436  TMBVline.append(int(x1))
6437  TMBVline.append(int(y1))
6438  else:
6439  TMBVline.append(int(x1))
6440  TMBVline.append(int(y1))
6441  ypvmb = y1
6442  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6443  Xfine = MouseX - X0L - x
6444  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
6445  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
6446  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6447  if y1 < Ymin: # clip waveform if going off grid
6448  y1 = Ymin
6449  if y1 > Ymax:
6450  y1 = Ymax
6451  if ZOHold.get() == 1:
6452  TMCVline.append(int(x1))
6453  TMCVline.append(int(ypvmc))
6454  TMCVline.append(int(x1))
6455  TMCVline.append(int(y1))
6456  else:
6457  TMCVline.append(int(x1))
6458  TMCVline.append(int(y1))
6459  ypvmc = y1
6460  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6461  Xfine = MouseX - X0L - x
6462  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
6463  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
6464  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6465  if y1 < Ymin: # clip waveform if going off grid
6466  y1 = Ymin
6467  if y1 > Ymax:
6468  y1 = Ymax
6469  if ZOHold.get() == 1:
6470  TMDVline.append(int(x1))
6471  TMDVline.append(int(ypvmd))
6472  TMDVline.append(int(x1))
6473  TMDVline.append(int(y1))
6474  else:
6475  TMDVline.append(int(x1))
6476  TMDVline.append(int(y1))
6477  ypvmd = y1
6478  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6479  Xfine = MouseX - X0L - x
6480  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
6481  if ShowC2_I.get() == 1:
6482  ytemp = IBuffB[t]
6483  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6484  if yi1 < Ymin:
6485  yi1 = Ymin
6486  if yi1 > Ymax:
6487  yi1 = Ymax
6488  if (ZOHold.get() == 1):
6489  T2Iline.append(int(x1))
6490  T2Iline.append(int(ypi2))
6491  T2Iline.append(int(x1))
6492  T2Iline.append(int(yi1))
6493  else:
6494  T2Iline.append(int(x1))
6495  T2Iline.append(int(yi1))
6496  DiY2 = ypi2 - yi1
6497  ypi2 = yi1
6498  if MathTrace.get() > 0:
6499  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6500  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6501 
6502  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6503  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6504 
6505  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6506  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6507 
6508  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6509  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6510  ytemp = YIconv1 * (Ypower - CHAIOffset)
6511  y1 = int(c1 - ytemp)
6512 
6513  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6514  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6515  ytemp = YIconv2 * (Ypower - CHBIOffset)
6516  y1 = int(c2 - ytemp)
6517 
6518  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6519  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6520  ytemp = YIconv1 * (Yohms - CHAIOffset)
6521  y1 = int(c1 - ytemp)
6522 
6523  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6524  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6525  ytemp = YIconv2 * (Yohms - CHBIOffset)
6526  y1 = int(c2 - ytemp)
6527 
6528  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6529  Ydif = (IBuffA[t] - IBuffB[t])# in mA
6530  ytemp = YIconv1 * (Ydif - CHAIOffset)
6531  y1 = int(c2 - ytemp)
6532 
6533  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6534  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6535  ytemp = YIconv2 * (Ydif - CHBIOffset)
6536  y1 = int(c2 - ytemp)
6537 
6538  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6539  try:
6540  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6541  except:
6542  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6543 
6544  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6545  try:
6546  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6547  except:
6548  Y1 = (IBuffB[t] / 0.000001)
6549  ytemp = YIconv2 * (Y1 - CHBIOffset)
6550  y1 = int(c2 - ytemp)
6551 
6552  elif MathTrace.get() == 12: # plot from equation string
6553  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6554  try:
6555  MathResult = eval(MathString)
6556  MathResult = MathResult - CHMOffset
6557  y1 = int(c1 - YconvM * MathResult)
6558  except:
6559  RUNstatus.set(0)
6560  x = Xlimit + 1 # exit loop
6561 
6562  if y1 < Ymin: # clip waveform if going off grid
6563  y1 = Ymin
6564  if y1 > Ymax:
6565  y1 = Ymax
6566  if ZOHold.get() == 1: # connet the dots with stair step
6567  Tmathline.append(int(x1))
6568  Tmathline.append(int(ypm))
6569  Tmathline.append(int(x1))
6570  Tmathline.append(int(y1))
6571  else: # connet the dots with single line
6572  Tmathline.append(int(x1))
6573  Tmathline.append(int(y1))
6574  ypm = y1
6575  if Show_MathX.get() > 0:
6576  try:
6577  MathResult = eval(MathXString)
6578  MathResult = MathResult - CHMXOffset
6579  y1 = int(c1 - XconvMxy * MathResult)
6580  except:
6581  RUNstatus.set(0)
6582  x = Xlimit + 1 # exit loop
6583 
6584  if y1 < Ymin: # clip waveform if going off grid
6585  y1 = Ymin
6586  if y1 > Ymax:
6587  y1 = Ymax
6588  if ZOHold.get() == 1: # connet the dots with stair step
6589  TMXline.append(int(x1))
6590  TMXline.append(int(ypmx))
6591  TMXline.append(int(x1))
6592  TMXline.append(int(y1))
6593  else: # connet the dots with single line
6594  TMXline.append(int(x1))
6595  TMXline.append(int(y1))
6596  ypmx = y1
6597  if Show_MathY.get() > 0:
6598  try:
6599  MathResult = eval(MathYString)
6600  MathResult = MathResult - CHMYOffset
6601  y1 = int(c1 - YconvMxy * MathResult)
6602  except:
6603  RUNstatus.set(0)
6604  x = Xlimit + 1 # exit loop
6605 
6606  if y1 < Ymin: # clip waveform if going off grid
6607  y1 = Ymin
6608  if y1 > Ymax:
6609  y1 = Ymax
6610  if ZOHold.get() == 1: # connet the dots with stair step
6611  TMYline.append(int(x1))
6612  TMYline.append(int(ypmy))
6613  TMYline.append(int(x1))
6614  TMYline.append(int(y1))
6615  else: # connet the dots with single line
6616  TMYline.append(int(x1))
6617  TMYline.append(int(y1))
6618  ypmy = y1
6619  if D0.get() == 0:
6620  yd = int(c1 - (( DBuff0[t]*0.9 - 5 ) * Dconv))
6621  D0line.append(int(x1))
6622  D0line.append(yd)
6623  if D1.get() == 0:
6624  yd = int(c1 - (( DBuff1[t]*0.9 - 4 ) * Dconv))
6625  D1line.append(int(x1))
6626  D1line.append(yd)
6627  if D2.get() == 0:
6628  yd = int(c1 - (( DBuff2[t]*0.9 - 3 ) * Dconv))
6629  D2line.append(int(x1))
6630  D2line.append(yd)
6631  if D3.get() == 0:
6632  yd = int(c1 - (( DBuff3[t]*0.9 - 2 ) * Dconv))
6633  D3line.append(int(x1))
6634  D3line.append(yd)
6635 
6636  # remember trace verticle pixel at X mouse location
6637  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
6638  Xfine = MouseX - X0L - x
6639  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
6640  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
6641  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
6642  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
6643  t = int(t + Tstep)
6644  x = x + Xstep
6645  xa = xa + Xstep
6646 
6647  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
6648  Xstep = 1
6649  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
6650  x1 = 0.0 # x position of trace line
6651  ylo = 0.0 # ymin position of trace 1 line
6652  yhi = 0.0 # ymax position of trace 1 line
6653 
6654  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6655  if t > len(VBuffA)-1:
6656  t = 0
6657  if t < 0:
6658  t = 0
6659  x = 0 # Horizontal screen pixel
6660  ft = t # time point with fractions
6661  while (x <= GRW):
6662  if (t < TRACEsize):
6663  if (t >= len(VBuffA)):
6664  t = len(VBuffA)-2
6665  x = GRW
6666  x1 = x + X0L
6667  ylo = VBuffA[t] - CHAOffset
6668  ilo = IBuffA[t] - CHAIOffset
6669  yhi = ylo
6670  ihi = ilo
6671  n = t
6672  while n < (t + Tstep) and n < TRACEsize:
6673  if ( ShowC1_V.get() == 1 ):
6674  v = VBuffA[t] - CHAOffset
6675  if v < ylo:
6676  ylo = v
6677  if v > yhi:
6678  yhi = v
6679  if ( ShowC1_I.get() == 1 ):
6680  i = IBuffA[t] - CHAIOffset
6681  if i < ilo:
6682  ilo = i
6683  if i > ihi:
6684  ihi = i
6685  n = n + 1
6686  if ( ShowC1_V.get() == 1 ):
6687  ylo = int(c1 - Yconv1 * ylo)
6688  yhi = int(c1 - Yconv1 * yhi)
6689  if (ylo < Ymin):
6690  ylo = Ymin
6691  if (ylo > Ymax):
6692  ylo = Ymax
6693  if (yhi < Ymin):
6694  yhi = Ymin
6695  if (yhi > Ymax):
6696  yhi = Ymax
6697  T1Vline.append(int(x1))
6698  T1Vline.append(int(ylo))
6699  T1Vline.append(int(x1))
6700  T1Vline.append(int(yhi))
6701  ypv1 = ylo
6702  if ( ShowC1_I.get() == 1 ):
6703  ilo = int(c1 - YIconv1 * ilo)
6704  ihi = int(c1 - YIconv1 * ihi)
6705  if (ilo < Ymin):
6706  ilo = Ymin
6707  if (ilo > Ymax):
6708  ilo = Ymax
6709  if (ihi < Ymin):
6710  ihi = Ymin
6711  if (ihi > Ymax):
6712  ihi = Ymax
6713  T1Iline.append(int(x1))
6714  T1Iline.append(int(ilo))
6715  T1Iline.append(int(x1))
6716  T1Iline.append(int(ihi))
6717  ypi1 = ilo
6718  ylo = VBuffB[t] - CHBOffset
6719  ilo = IBuffB[t] - CHBIOffset
6720  yhi = ylo
6721  ihi = ilo
6722  n = t
6723  if MuxScreenStatus.get() == 0:
6724  while n < (t + Tstep) and n < TRACEsize:
6725  if ( ShowC2_V.get() == 1 ):
6726  v = VBuffB[t] - CHBOffset
6727  if v < ylo:
6728  ylo = v
6729  if v > yhi:
6730  yhi = v
6731  if ( ShowC2_I.get() == 1 ):
6732  i = IBuffB[t] - CHBIOffset
6733  if i < ilo:
6734  ilo = i
6735  if i > ihi:
6736  ihi = i
6737  n = n + 1
6738  if ( ShowC2_V.get() == 1 ):
6739  ylo = int(c2 - Yconv2 * ylo)
6740  yhi = int(c2 - Yconv2 * yhi)
6741  if (ylo < Ymin):
6742  ylo = Ymin
6743  if (ylo > Ymax):
6744  ylo = Ymax
6745 
6746  if (yhi < Ymin):
6747  yhi = Ymin
6748  if (yhi > Ymax):
6749  yhi = Ymax
6750  T2Vline.append(int(x1))
6751  T2Vline.append(int(ylo))
6752  T2Vline.append(int(x1))
6753  T2Vline.append(int(yhi))
6754  ypv2 = ylo
6755  if ( ShowC2_I.get() == 1 ):
6756  ilo = int(c2 - YIconv2 * ilo)
6757  ihi = int(c2 - YIconv2 * ihi)
6758  if (ilo < Ymin):
6759  ilo = Ymin
6760  if (ilo > Ymax):
6761  ilo = Ymax
6762  if (ihi < Ymin):
6763  ihi = Ymin
6764  if (ihi > Ymax):
6765  ihi = Ymax
6766  T2Iline.append(int(x1))
6767  T2Iline.append(int(ilo))
6768  T2Iline.append(int(x1))
6769  T2Iline.append(int(ihi))
6770  ypi2 = ilo
6771  else:
6772  if Show_CBA.get() == 1 and len(VBuffMA)>4:
6773  if t < len(VBuffMA):
6774  ylo = VBuffMA[t] - CHBAOffset
6775  yhi = ylo
6776  n = t
6777  while n < (t + Tstep) and n < len(VBuffMA):
6778  v = VBuffMA[t] - CHBAOffset
6779  if v < ylo:
6780  ylo = v
6781  if v > yhi:
6782  yhi = v
6783  n = n + 1
6784  ylo = int(c2 - YconvMA * ylo)
6785  yhi = int(c2 - YconvMA * yhi)
6786  if (ylo < Ymin):
6787  ylo = Ymin
6788  if (ylo > Ymax):
6789  ylo = Ymax
6790  if (yhi < Ymin):
6791  yhi = Ymin
6792  if (yhi > Ymax):
6793  yhi = Ymax
6794  TMAVline.append(int(x1))
6795  TMAVline.append(int(ylo))
6796  TMAVline.append(int(x1))
6797  TMAVline.append(int(yhi))
6798  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6799  MouseMuxA = ylo
6800  if Show_CBB.get() == 1 and len(VBuffMB)>4:
6801  if t < len(VBuffMB):
6802  ylo = VBuffMB[t] - CHBBOffset
6803  yhi = ylo
6804  n = t
6805  while n < (t + Tstep) and n < len(VBuffMB):
6806  v = VBuffMB[t] - CHBBOffset
6807  if v < ylo:
6808  ylo = v
6809  if v > yhi:
6810  yhi = v
6811  n = n + 1
6812  ylo = int(c2 - YconvMB * ylo)
6813  yhi = int(c2 - YconvMB * yhi)
6814  if (ylo < Ymin):
6815  ylo = Ymin
6816  if (ylo > Ymax):
6817  ylo = Ymax
6818  if (yhi < Ymin):
6819  yhi = Ymin
6820  if (yhi > Ymax):
6821  yhi = Ymax
6822  TMBVline.append(int(x1))
6823  TMBVline.append(int(ylo))
6824  TMBVline.append(int(x1))
6825  TMBVline.append(int(yhi))
6826  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6827  MouseMuxB = ylo
6828  if Show_CBC.get() == 1 and len(VBuffMC)>4:
6829  if t < len(VBuffMC):
6830  ylo = VBuffMC[t] - CHBCOffset
6831  yhi = ylo
6832  n = t
6833  while n < (t + Tstep) and n < len(VBuffMC):
6834  v = VBuffMC[t] - CHBCOffset
6835  if v < ylo:
6836  ylo = v
6837  if v > yhi:
6838  yhi = v
6839  n = n + 1
6840  ylo = int(c2 - YconvMC * ylo)
6841  yhi = int(c2 - YconvMC * yhi)
6842  if (ylo < Ymin):
6843  ylo = Ymin
6844  if (ylo > Ymax):
6845  ylo = Ymax
6846  if (yhi < Ymin):
6847  yhi = Ymin
6848  if (yhi > Ymax):
6849  yhi = Ymax
6850  TMCVline.append(int(x1))
6851  TMCVline.append(int(ylo))
6852  TMCVline.append(int(x1))
6853  TMCVline.append(int(yhi))
6854  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6855  MouseMuxC = ylo
6856  if Show_CBD.get() == 1 and len(VBuffMD)>4:
6857  if t < len(VBuffMD):
6858  ylo = VBuffMD[t] - CHBDOffset
6859  yhi = ylo
6860  n = t
6861  while n < (t + Tstep) and n < len(VBuffMD):
6862  v = VBuffMD[t] - CHBDOffset
6863  if v < ylo:
6864  ylo = v
6865  if v > yhi:
6866  yhi = v
6867  n = n + 1
6868  ylo = int(c2 - YconvMD * ylo)
6869  yhi = int(c2 - YconvMD * yhi)
6870  if (ylo < Ymin):
6871  ylo = Ymin
6872  if (ylo > Ymax):
6873  ylo = Ymax
6874  if (yhi < Ymin):
6875  yhi = Ymin
6876  if (yhi > Ymax):
6877  yhi = Ymax
6878  TMDVline.append(int(x1))
6879  TMDVline.append(int(ylo))
6880  TMDVline.append(int(x1))
6881  TMDVline.append(int(yhi))
6882  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6883  MouseMuxD = ylo
6884  if ( ShowC2_I.get() == 1 ):
6885  while n < (t + Tstep) and n < TRACEsize:
6886  i = IBuffB[t] - CHBIOffset
6887  if i < ilo:
6888  ilo = i
6889  if i > ihi:
6890  ihi = i
6891  n = n + 1
6892  ilo = int(c2 - YIconv2 * ilo)
6893  ihi = int(c2 - YIconv2 * ihi)
6894  if (ilo < Ymin):
6895  ilo = Ymin
6896  if (ilo > Ymax):
6897  ilo = Ymax
6898  if (ihi < Ymin):
6899  ihi = Ymin
6900  if (ihi > Ymax):
6901  ihi = Ymax
6902  T2Iline.append(int(x1))
6903  T2Iline.append(int(ilo))
6904  T2Iline.append(int(x1))
6905  T2Iline.append(int(ihi))
6906  if MathTrace.get() > 0:
6907  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6908  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6909 
6910  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6911  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6912 
6913  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6914  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6915 
6916  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6917  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6918  ytemp = YIconv1 * (Ypower - CHAIOffset)
6919  y1 = int(c1 - ytemp)
6920 
6921  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6922  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6923  ytemp = YIconv2 * (Ypower - CHBIOffset)
6924  y1 = int(c2 - ytemp)
6925 
6926  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6927  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6928  ytemp = YIconv1 * (Yohms- CHAIOffset)
6929  y1 = int(c1 - ytemp)
6930 
6931  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6932  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6933  ytemp = YIconv2 * (Yohms - CHBIOffset)
6934  y1 = int(c2 - ytemp)
6935 
6936  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6937  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
6938  ytemp = YIconv1 * (Ydif - CHAIOffset)
6939  y1 = int(c2 - ytemp)
6940 
6941  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6942  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6943  ytemp = YIconv2 * (Ydif - CHBIOffset)
6944  y1 = int(c2 - ytemp)
6945 
6946  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6947  try:
6948  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6949  except:
6950  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6951  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6952  try:
6953  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6954  except:
6955  Y1 = (IBuffB[t] / 0.000001)
6956  ytemp = YIconv2 * (Y1 - CHBIOffset)
6957  y1 = int(c2 - ytemp)
6958 
6959  elif MathTrace.get() == 12: # plot from equation string
6960  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6961  try:
6962  MathResult = eval(MathString)
6963  MathResult = MathResult - CHMOffset
6964  y1 = int(c1 - YconvM * MathResult)
6965  except:
6966  RUNstatus.set(0)
6967  x = GRW + 1
6968 
6969  if (y1 < Ymin):
6970  y1 = Ymin
6971  if (y1 > Ymax):
6972  y1 = Ymax
6973  if (ZOHold.get() == 1):
6974  Tmathline.append(int(x1))
6975  Tmathline.append(int(ypm))
6976  Tmathline.append(int(x1))
6977  Tmathline.append(int(y1))
6978  else:
6979  Tmathline.append(int(x1))
6980  Tmathline.append(int(y1))
6981  ypm = y1
6982  if Show_MathX.get() > 0:
6983  try:
6984  MathResult = eval(MathXString)
6985  MathResult = MathResult - CHMXOffset
6986  y1 = int(c1 - XconvMxy * MathResult)
6987  except:
6988  RUNstatus.set(0)
6989  x = GRW + 1
6990 
6991  if y1 < Ymin: # clip waveform if going off grid
6992  y1 = Ymin
6993  if y1 > Ymax:
6994  y1 = Ymax
6995  if ZOHold.get() == 1: # connet the dots with stair step
6996  TMXline.append(int(x1))
6997  TMXline.append(int(ypmx))
6998  TMXline.append(int(x1))
6999  TMXline.append(int(y1))
7000  else: # connet the dots with single line
7001  TMXline.append(int(x1))
7002  TMXline.append(int(y1))
7003  ypmx = y1
7004  if Show_MathY.get() > 0:
7005  try:
7006  MathResult = eval(MathYString)
7007  MathResult = MathResult - CHMYOffset
7008  y1 = int(c1 - YconvMxy * MathResult)
7009  except:
7010  RUNstatus.set(0)
7011  x = GRW + 1
7012 
7013  if y1 < Ymin: # clip waveform if going off grid
7014  y1 = Ymin
7015  if y1 > Ymax:
7016  y1 = Ymax
7017  if ZOHold.get() == 1: # connet the dots with stair step
7018  TMYline.append(int(x1))
7019  TMYline.append(int(ypmy))
7020  TMYline.append(int(x1))
7021  TMYline.append(int(y1))
7022  else: # connet the dots with single line
7023  TMYline.append(int(x1))
7024  TMYline.append(int(y1))
7025  ypmy = y1
7026  ft = ft + Tstep
7027  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
7028  MouseCAV = ypv1
7029  MouseCAI = ypi1
7030  MouseCBV = ypv2
7031  MouseCBI = ypi2
7032  t = int(ft)
7033  if (t > len(VBuffA)):
7034  t = len(VBuffA)-2
7035  x = GRW
7036  x = x + Xstep
7037 
7038  # Make trigger triangle pointer
7039  Triggerline = [] # Trigger pointer
7040  Triggersymbol = [] # Trigger symbol
7041  if TgInput.get() > 0 or ChopTrig.get() > 0:
7042  if TgInput.get() == 1 or TgInput.get() == 5: # triggering on CA-V
7043  x1 = X0L
7044  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) #
7045  y1 = int(c1 - ytemp)
7046  elif TgInput.get() == 2: # triggering on CA-I
7047  x1 = X0L+GRW
7048  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
7049  elif TgInput.get() == 3: # triggering on CB-V
7050  x1 = X0L
7051  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) #
7052  y1 = int(c2 - ytemp)
7053  elif TgInput.get() == 4: # triggering on CB-I
7054  x1 = X0L+GRW
7055  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
7056  elif ChopTrig.get() == 1: # triggering on Mux A
7057  x1 = X0L
7058  ytemp = YconvMA * (float(TRIGGERlevel)-CHBAOffset) #
7059  y1 = int(c1 - ytemp)
7060  elif ChopTrig.get() == 2: # triggering on Mux B
7061  x1 = X0L
7062  ytemp = YconvMB * (float(TRIGGERlevel)-CHBBOffset) #
7063  y1 = int(c1 - ytemp)
7064  elif ChopTrig.get() == 3: # triggering on Mux A
7065  x1 = X0L
7066  ytemp = YconvMC * (float(TRIGGERlevel)-CHBCOffset) #
7067  y1 = int(c1 - ytemp)
7068  elif ChopTrig.get() == 4: # triggering on Mux A
7069  x1 = X0L
7070  ytemp = YconvMD * (float(TRIGGERlevel)-CHBDOffset) #
7071  y1 = int(c1 - ytemp)
7072  #
7073  if (y1 < Ymin):
7074  y1 = Ymin
7075  if (y1 > Ymax):
7076  y1 = Ymax
7077  Triggerline.append(int(x1-5))
7078  Triggerline.append(int(y1+5))
7079  Triggerline.append(int(x1+5))
7080  Triggerline.append(int(y1))
7081  Triggerline.append(int(x1-5))
7082  Triggerline.append(int(y1-5))
7083  Triggerline.append(int(x1-5))
7084  Triggerline.append(int(y1+5))
7085  x1 = X0L + (GRW/2)
7086  if TgEdge.get() == 0: # draw rising edge symbol
7087  y1 = -3
7088  y2 = -13
7089  else:
7090  y1 = -13
7091  y2 = -3
7092  Triggersymbol.append(int(x1-10))
7093  Triggersymbol.append(int(Ymin+y1))
7094  Triggersymbol.append(int(x1))
7095  Triggersymbol.append(int(Ymin+y1))
7096  Triggersymbol.append(int(x1))
7097  Triggersymbol.append(int(Ymin+y2))
7098  Triggersymbol.append(int(x1+10))
7099  Triggersymbol.append(int(Ymin+y2))
7100 
7102  global VBuffA, VBuffB, IBuffA, IBuffB
7103  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
7104  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7105  global XYlineVA, XYlineVB, XYlineIA, XYlineIB, XYlineM, XYlineMX, XYlineMY
7106  global MathXString, MathYString, MathAxis, MathXAxis, MathYAxis
7107  global HoldOff, HoldOffentry
7108  global X0LXY, Y0TXY, GRWXY, GRHXY
7109  global YminXY, YmaxXY, XminXY, XmaxXY
7110  global SHOWsamples, ZOHold, AWGBMode
7111  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
7112  global TRACES, TRACESread, RUNstatus
7113  global Xsignal, YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
7114  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
7115  global TMpdiv # Array with time / div values in ms
7116  global TMsb # Time per div spin box variable
7117  global TIMEdiv # current spin box value
7118  global SAMPLErate
7119  global SCstart, MathString
7120  global TRIGGERsample, TRACEsize, DX
7121  global TRIGGERlevel, TRIGGERentry, AutoLevel
7122  global InOffA, InGainA, InOffB, InGainB
7123  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
7124  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
7125  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7126  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
7127  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
7128  global HozPoss, HozPossentry
7129 
7130  # Set the TRACEsize variable
7131  if len(VBuffA) < 100:
7132  return
7133  TRACEsize = SHOWsamples # Set the trace length
7134  SCstart = 0
7135  yloVA = yloVB = yloIA = yloIB = yloM = yloMX = yloMY = 0.0
7136  xlo = 0.0
7137  # get the vertical ranges
7138  try:
7139  CH1pdvRange = float(eval(CHAsbxy.get()))
7140  except:
7141  CHAsbxy.delete(0,END)
7142  CHAsbxy.insert(0, CH1pdvRange)
7143  try:
7144  CH2pdvRange = float(eval(CHBsbxy.get()))
7145  except:
7146  CHBsbxy.delete(0,END)
7147  CHBsbxy.insert(0, CH2pdvRange)
7148  try:
7149  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7150  except:
7151  CHAIsbxy.delete(0,END)
7152  CHAIsbxy.insert(0, CH1IpdvRange)
7153  try:
7154  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7155  except:
7156  CHBIsbxy.delete(0,END)
7157  CHBIsbxy.insert(0, CH2IpdvRange)
7158  # get the vertical offsets
7159  try:
7160  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7161  except:
7162  CHAVPosEntryxy.delete(0,END)
7163  CHAVPosEntryxy.insert(0, CHAOffset)
7164  try:
7165  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7166  except:
7167  CHAIPosEntryxy.delete(0,END)
7168  CHAIPosEntryxy.insert(0, CHAIOffset)
7169  try:
7170  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7171  except:
7172  CHBVPosEntry.delete(0,END)
7173  CHBVPosEntry.insert(0, CHBOffset)
7174  try:
7175  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7176  except:
7177  CHBIPosEntryxy.delete(0,END)
7178  CHBIPosEntryxy.insert(0, CHBIOffset)
7179  # prevent divide by zero error
7180  if CH1pdvRange < 0.001:
7181  CH1pdvRange = 0.001
7182  if CH2pdvRange < 0.001:
7183  CH2pdvRange = 0.001
7184  if CH1IpdvRange < 0.1:
7185  CH1IpdvRange = 0.1
7186  if CH2IpdvRange < 0.1:
7187  CH2IpdvRange = 0.1
7188  #
7189  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
7190  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
7191  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
7192  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
7193  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
7194  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
7195  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
7196  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
7197 
7198  if MathAxis == "V-A":
7199  YconvM = Yconv1
7200  CHMOffset = CHAOffset
7201  elif MathAxis == "V-B":
7202  YconvM = Yconv2
7203  CHMOffset = CHBOffset
7204  elif MathAxis == "I-A":
7205  YconvM = YIconv1
7206  CHMOffset = CHAIOffset
7207  elif MathAxis == "I-B":
7208  YconvM = YIconv2
7209  CHMOffset = CHBIOffset
7210  else:
7211  YconvM = Yconv1
7212  CHMYOffset = CHAOffset
7213  if MathYAxis == "V-A":
7214  YconvMy = Yconv1
7215  CHMYOffset = CHAOffset
7216  elif MathYAxis == "V-B":
7217  YconvMy = Yconv2
7218  CHMYOffset = CHBOffset
7219  elif MathYAxis == "I-A":
7220  YconvMy = YIconv1
7221  CHMYOffset = CHAIOffset
7222  elif MathYAxis == "I-B":
7223  YconvMy = YIconv2
7224  CHMYOffset = CHBIOffset
7225  else:
7226  YconvMy = Yconv1
7227  CHMYOffset = CHAOffset
7228  if MathXAxis == "V-A":
7229  XconvMxy = Xconv1
7230  CHMXOffset = CHAOffset
7231  YconvMx = Yconv1
7232  elif MathXAxis == "V-B":
7233  XconvMxy = Xconv2
7234  CHMXOffset = CHBOffset
7235  YconvMx = Yconv2
7236  elif MathXAxis == "I-A":
7237  XconvMxy = XIconv1
7238  CHMXOffset = CHAIOffset
7239  YconvMx = YIconv1
7240  elif MathXAxis == "I-B":
7241  XconvMxy = XIconv2
7242  CHMXOffset = CHBIOffset
7243  YconvMx = YIconv2
7244  else:
7245  XconvMxy = Xconv1
7246  CHMXOffset = CHAOffset
7247  YconvMx = Yconv1
7248  # draw an X/Y plot
7249  XYlineVA = [] # XY Trace lines
7250  XYlineVB = []
7251  XYlineIA = []
7252  XYlineIB = []
7253  XYlineM = []
7254  XYlineMX = []
7255  XYlineMY = []
7256  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
7257  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
7258  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7259  while (t < TRACEsize):
7260  # calculate X axis points
7261  if Xsignal.get() == 1: # CVA
7262  xlo = VBuffA[t] - CHAOffset
7263  xlo = int(c2 + Xconv1 * xlo)
7264  elif Xsignal.get() == 3: # CVB
7265  xlo = VBuffB[t] - CHBOffset
7266  xlo = int(c2 + Xconv2 * xlo)
7267  elif Xsignal.get() == 2: # CAI
7268  xlo = (IBuffA[t]) - CHAIOffset
7269  xlo = int(c2 + XIconv1 * xlo)
7270  elif Xsignal.get() == 4: # CBI
7271  xlo = (IBuffB[t]) - CHBIOffset
7272  xlo = int(c2 + XIconv2 * xlo)
7273  elif Xsignal.get() == 5: # Math
7274  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7275  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
7276  xlo = int(c2 + Xconv1 * xlo)
7277  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7278  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
7279  xlo = int(c2 + Xconv2 * xlo)
7280  else:
7281  try:
7282  MathResult = eval(MathXString)
7283  MathResult = MathResult - CHMXOffset
7284  xlo = int(c2 + XconvMxy * MathResult)
7285  except:
7286  RUNstatus.set(0)
7287  if xlo < XminXY: # clip waveform if going off grid
7288  xlo = XminXY
7289  if xlo > XmaxXY:
7290  xlo = XmaxXY
7291  # calculate Y axis points
7292  if YsignalVA.get() == 1: # CAV
7293  yloVA = VBuffA[t] - CHAOffset
7294  yloVA = int(c1 - Yconv1 * yloVA)
7295  if yloVA < YminXY: # clip waveform if going off grid
7296  yloVA = YminXY
7297  if yloVA > YmaxXY:
7298  yloVA = YmaxXY
7299  XYlineVA.append(int(xlo))
7300  XYlineVA.append(int(yloVA))
7301  if YsignalVB.get() == 1: # CBV
7302  yloVB = VBuffB[t] - CHBOffset
7303  yloVB = int(c1 - Yconv2 * yloVB)
7304  if yloVB < YminXY: # clip waveform if going off grid
7305  yloVB = YminXY
7306  if yloVB > YmaxXY:
7307  yloVB = YmaxXY
7308  XYlineVB.append(int(xlo))
7309  XYlineVB.append(int(yloVB))
7310  if YsignalIB.get() == 1: # CBI
7311  yloIB = (IBuffB[t]) - CHBIOffset
7312  yloIB = int(c1 - YIconv2 * yloIB)
7313  if yloIB < YminXY: # clip waveform if going off grid
7314  yloIB = YminXY
7315  if yloIB > YmaxXY:
7316  yloIB = YmaxXY
7317  XYlineIB.append(int(xlo))
7318  XYlineIB.append(int(yloIB))
7319  if YsignalIA.get() == 1: # CAI
7320  yloIA = (IBuffA[t]) - CHAIOffset
7321  yloIA = int(c1 - YIconv1 * yloIA)
7322  if yloIA < YminXY: # clip waveform if going off grid
7323  yloIA = YminXY
7324  if yloIA > YmaxXY:
7325  yloIA = YmaxXY
7326  XYlineIA.append(int(xlo))
7327  XYlineIA.append(int(yloIA))
7328  if YsignalM.get() == 1: # Math
7329  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7330  yloM = VBuffA[t] - VBuffB[t] - CHAOffset
7331  yloM = int(c1 - Yconv1 * yloM)
7332  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7333  yloM = VBuffB[t] - VBuffA[t] - CHBOffset
7334  yloM = int(c1 - Yconv2 * yloM)
7335  else:
7336  try:
7337  MathResult = eval(MathString)
7338  MathResult = MathResult - CHMOffset
7339  yloM = int(c1 - YconvM * MathResult)
7340  except:
7341  RUNstatus.set(0)
7342  if yloM < YminXY: # clip waveform if going off grid
7343  yloM = YminXY
7344  if yloM > YmaxXY:
7345  yloM = YmaxXY
7346  XYlineM.append(int(xlo))
7347  XYlineM.append(int(yloM))
7348  if YsignalMX.get() == 1: # Math-X
7349  try:
7350  MathResult = eval(MathXString)
7351  MathResult = MathResult - CHMXOffset
7352  yloMX = int(c1 - YconvMx * MathResult)
7353  except:
7354  RUNstatus.set(0)
7355  if yloMX < YminXY: # clip waveform if going off grid
7356  yloMX = YminXY
7357  if yloMX > YmaxXY:
7358  yloMX = YmaxXY
7359  XYlineMX.append(int(xlo))
7360  XYlineMX.append(int(yloMX))
7361  if YsignalMY.get() == 1: # Math-Y
7362  try:
7363  MathResult = eval(MathYString)
7364  MathResult = MathResult - CHMYOffset
7365  yloMY = int(c1 - YconvMy * MathResult)
7366  except:
7367  RUNstatus.set(0)
7368  if yloMY < YminXY: # clip waveform if going off grid
7369  yloMY = YminXY
7370  if yloMY > YmaxXY:
7371  yloMY = YmaxXY
7372  XYlineMY.append(int(xlo))
7373  XYlineMY.append(int(yloMY))
7374 
7375  t = int(t + 1)
7376 
7378  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
7379  global TMXline, TMYline
7380  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
7381  global D0line, D1line, D2line, D3line, D0, D1, D2, D3
7382  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
7383  global VBuffA, VBuffB, IBuffA, IBuffB
7384  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
7385  global TMAVline, TMBVline, TMCVline, TMDVline, TMARline, TMBRline, TMCRline, TMDRline
7386  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
7387  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
7388  global X0L # Left top X value
7389  global Y0T # Left top Y value
7390  global GRW # Screenwidth
7391  global GRH # Screenheight
7392  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
7393  global LabelPlotText, PlotLabelText # plot custom label text flag
7394  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
7395  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
7396  global ShowXCur, ShowYCur, TCursor, VCursor
7397  global SHOWsamples # Number of samples in data record
7398  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Show_MathX, Show_MathY
7399  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
7400  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
7401  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
7402  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
7403  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7404  global CHAsb # V range spinbox Index for channel 1
7405  global CHBsb # V range spinbox Index for channel 2
7406  global CHAOffset # Position value for channel 1 V
7407  global CHBOffset # Position value for channel 2 V
7408  global CHAIsb # I range spinbox Index for channel 1
7409  global CHBIsb # I range spinbox Index for channel 2
7410  global CHAIOffset # Postion value for channel 1 I
7411  global CHBIOffset # position value for channel 2 I
7412  global TMpdiv # Array with time / div values in ms
7413  global TMsb # Time per div spin box variable
7414  global TIMEdiv, Mulx, DISsamples # current spin box value
7415  global SAMPLErate, contloop, discontloop, HtMulEntry
7416  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
7417  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
7418  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
7419  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
7420  global CANVASwidth, CANVASheight
7421  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7422  global ScreenTrefresh, SmoothCurves, Is_Triggered
7423  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7424  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7425  global InOffA, InGainA, InOffB, InGainB
7426  global CurOffA, CurOffB, CurGainA, CurGainB
7427  # Analog Mux channel measurement variables
7428  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
7429  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
7430  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
7431  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
7432  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
7433  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7434  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7435  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7436  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7437  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
7438  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7439  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7440  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
7441  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7442  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7443  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7444  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7445  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7446  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
7447  global D0, D1, D2, D3, D4, D5, D6, D7
7448  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
7449  global HozPoss, HozPossentry, First_Slow_sweep, Roll_Mode
7450  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7451  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7452  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
7453  #
7454  Ymin = Y0T # Minimum position of time grid (top)
7455  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
7456 
7457  # DISsamples = (10.0 * TIMEdiv) # grid width in time
7458  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
7459  # get the vertical ranges
7460  try:
7461  CH1pdvRange = float(eval(CHAsb.get()))
7462  except:
7463  CHAsb.delete(0,END)
7464  CHAsb.insert(0, CH1pdvRange)
7465  try:
7466  CH2pdvRange = float(eval(CHBsb.get()))
7467  except:
7468  CHBsb.delete(0,END)
7469  CHBsb.insert(0, CH2pdvRange)
7470  try:
7471  CH1IpdvRange = float(eval(CHAIsb.get()))
7472  except:
7473  CHAIsb.delete(0,END)
7474  CHAIsb.insert(0, CH1IpdvRange)
7475  try:
7476  CH2IpdvRange = float(eval(CHBIsb.get()))
7477  except:
7478  CHBIsb.delete(0,END)
7479  CHBIsb.insert(0, CH2IpdvRange)
7480  # get the vertical offsets
7481  try:
7482  CHAOffset = float(eval(CHAVPosEntry.get()))
7483  except:
7484  CHAVPosEntry.delete(0,END)
7485  CHAVPosEntry.insert(0, CHAOffset)
7486  try:
7487  CHAIOffset = float(eval(CHAIPosEntry.get()))
7488  except:
7489  CHAIPosEntry.delete(0,END)
7490  CHAIPosEntry.insert(0, CHAIOffset)
7491  try:
7492  CHBOffset = float(eval(CHBVPosEntry.get()))
7493  except:
7494  CHBVPosEntry.delete(0,END)
7495  CHBVPosEntry.insert(0, CHBOffset)
7496  try:
7497  CHBIOffset = float(eval(CHBIPosEntry.get()))
7498  except:
7499  CHBIPosEntry.delete(0,END)
7500  CHBIPosEntry.insert(0, CHBIOffset)
7501  try:
7502  HoldOff = float(eval(HoldOffentry.get()))
7503  if HoldOff < 0:
7504  HoldOff = 0
7505  except:
7506  HoldOffentry.delete(0,END)
7507  HoldOffentry.insert(0, HoldOff)
7508  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
7509  try:
7510  Mulx = float(eval(HtMulEntry.get()))
7511  if Mulx < 1:
7512  Mulx = 1
7513  except:
7514  Mulx = 1
7515  if EnableHSsampling > 0:
7516  HtMulEntry.delete(0,END)
7517  HtMulEntry.insert(0, 1)
7518  else:
7519  Mulx = 1
7520  # slide trace left right by HozPoss
7521  try:
7522  HozPoss = float(eval(HozPossentry.get()))
7523  except:
7524  HozPossentry.delete(0,END)
7525  HozPossentry.insert(0, HozPoss)
7526  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7527  try:
7528  CHMApdvRange = float(eval(CHB_Asb.get()))
7529  except:
7530  CHB_Asb.delete(0,END)
7531  CHB_Asb.insert(0, CHMApdvRange)
7532  try:
7533  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7534  except:
7535  CHB_Bsb.delete(0,END)
7536  CHB_Bsb.insert(0, CHMBpdvRange)
7537  try:
7538  CHMCpdvRange = float(eval(CHB_Csb.get()))
7539  except:
7540  CHB_Csb.delete(0,END)
7541  CHB_Csb.insert(0, CHMCpdvRange)
7542  try:
7543  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7544  except:
7545  CHB_Dsb.delete(0,END)
7546  CHB_Dsb.insert(0, CHMDpdvRange)
7547  if CHMApdvRange < 0.001:
7548  CHMApdvRange = 0.001
7549  if CHMBpdvRange < 0.001:
7550  CHMBpdvRange = 0.001
7551  if CHMCpdvRange < 0.001:
7552  CHMCpdvRange = 0.001
7553  if CHMDpdvRange < 0.001:
7554  CHMDpdvRange = 0.001
7555  try:
7556  CHBAOffset = float(eval(CHB_APosEntry.get()))
7557  except:
7558  CHB_APosEntry.delete(0,END)
7559  CHB_APosEntry.insert(0, CHBAOffset)
7560  try:
7561  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7562  except:
7563  CHB_BPosEntry.delete(0,END)
7564  CHB_BPosEntry.insert(0, CHBBOffset)
7565  try:
7566  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7567  except:
7568  CHB_CPosEntry.delete(0,END)
7569  CHB_CPosEntry.insert(0, CHBCOffset)
7570  try:
7571  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7572  except:
7573  CHB_DPosEntry.delete(0,END)
7574  CHB_DPosEntry.insert(0, CHBDOffset)
7575  # prevent divide by zero error
7576  if CH1pdvRange < 0.001:
7577  CH1pdvRange = 0.001
7578  if CH2pdvRange < 0.001:
7579  CH2pdvRange = 0.001
7580  if CH1IpdvRange < 0.1:
7581  CH1IpdvRange = 0.1
7582  if CH2IpdvRange < 0.1:
7583  CH2IpdvRange = 0.1
7584  vt = HoldOff + HozPoss # invert sign and scale to mSec
7585  if ScreenTrefresh.get() == 0:
7586  # Delete all items on the screen
7587  ca.delete(ALL) # remove all items
7588  MarkerNum = 0
7589  # Draw horizontal grid lines
7590  i = 0
7591  x1 = X0L
7592  x2 = X0L + GRW
7593  mg_siz = GRW/10.0
7594  mg_inc = mg_siz/5.0
7595  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
7596  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
7597  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
7598  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
7599  # vertical scale text labels
7600  RightOffset = FontSize * 3
7601  LeftOffset = int(FontSize/2)
7602  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7603  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
7604  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7605  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
7606  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7607  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
7608  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7609  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
7610  #
7611  while (i < 11):
7612  y = Y0T + i * GRH/10.0
7613  Dline = [x1,y,x2,y]
7614  if i == 5:
7615  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
7616  k = 0
7617  while (k < 10):
7618  l = 1
7619  while (l < 5):
7620  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
7621  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7622  l = l + 1
7623  k = k + 1
7624  else:
7625  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7626 
7627  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7628  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7629  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
7630  Vaxis_label = str(round(Vaxis_value,3 ))
7631  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
7632 
7633  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7634  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7635  Iaxis_label = str(round(Iaxis_value, 3))
7636  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
7637 
7638  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7639  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7640  Vaxis_label = str(round(Vaxis_value, 3))
7641  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7642 
7643  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7644  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7645  Iaxis_label = str(round(Iaxis_value, 3))
7646  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
7647  if MuxScreenStatus.get() == 1:
7648  if Show_CBA.get() == 1:
7649  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
7650  Vaxis_label = str(round(Vaxis_value, 3))
7651  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7652  if Show_CBB.get() == 1:
7653  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
7654  Iaxis_label = str(round(Iaxis_value, 3))
7655  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
7656  if Show_CBC.get() == 1:
7657  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
7658  Iaxis_label = str(round(Iaxis_value, 3))
7659  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
7660  if Show_CBD.get() == 1:
7661  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
7662  Iaxis_label = str(round(Iaxis_value, 3))
7663  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
7664  i = i + 1
7665  # Draw vertical grid lines
7666  i = 0
7667  y1 = Y0T
7668  y2 = Y0T + GRH
7669  mg_siz = GRH/10.0
7670  mg_inc = mg_siz/5.0
7671  vx = TIMEdiv/Mulx
7672  vt = HoldOff/Mulx # invert sign and scale to mSec
7673  # vx = TIMEdiv
7674  while (i < 11):
7675  x = X0L + i * GRW/10.0
7676  Dline = [x,y1,x,y2]
7677  if (i == 5):
7678  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
7679  k = 0
7680  while (k < 10):
7681  l = 1
7682  while (l < 5):
7683  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
7684  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7685  l = l + 1
7686  k = k + 1
7687  #
7688  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7689  if vx >= 1000:
7690  axis_value = ((i * vx)+ vt) / 1000.0
7691  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7692  if vx < 1000 and vx >= 1:
7693  axis_value = (i * vx) + vt
7694  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7695  if vx < 1:
7696  axis_value = ((i * vx) + vt) * 1000.0
7697  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7698  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7699  else:
7700  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7701  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7702  if vx >= 1000:
7703  axis_value = ((i * vx)+ vt) / 1000.0
7704  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7705  if vx < 1000 and vx >= 1:
7706  axis_value = (i * vx) + vt
7707  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7708  if vx < 1:
7709  axis_value = ((i * vx) + vt) * 1000.0
7710  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7711  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7712 
7713  i = i + 1
7714  # Write the trigger line if available
7715  if Roll_Mode.get() == 0: # Don't show trigger indicator when in Roll Mode
7716  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
7717  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
7718  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
7719  if TgInput.get() == 1:
7720  TgLabel = "CA-V"
7721  if TgInput.get() == 2:
7722  TgLabel = "CA-I"
7723  if TgInput.get() == 3:
7724  TgLabel = "CB-V"
7725  if TgInput.get() == 4:
7726  TgLabel = "CB-I"
7727  if TgInput.get() == 5:
7728  TgLabel = "VA or VB"
7729  if TgInput.get() == 6:
7730  TgLabel = "Alternate"
7731  if ChopTrig.get() == 1:
7732  TgLabel = "Mux A"
7733  if ChopTrig.get() == 2:
7734  TgLabel = "Mux B"
7735  if ChopTrig.get() == 3:
7736  TgLabel = "Mux C"
7737  if ChopTrig.get() == 4:
7738  TgLabel = "Mux D"
7739  if Is_Triggered == 1:
7740  TgLabel = TgLabel + " Triggered"
7741  else:
7742  TgLabel = TgLabel + " Not Triggered"
7743  if SingleShot.get() > 0:
7744  TgLabel = TgLabel + " Armed"
7745  x = X0L + (GRW/2) + 12
7746  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
7747  # Draw T - V Cursor lines if required
7748  if MarkerScale.get() == 0:
7749  Yconv1 = float(GRH/10.0) / CH1pdvRange
7750  Yoffset1 = CHAOffset
7751  COLORmarker = COLORtrace1
7752  Units = " V"
7753  if MarkerScale.get() == 1:
7754  MouseY = MouseCAV
7755  Yconv1 = float(GRH/10.0) / CH1pdvRange
7756  Yoffset1 = CHAOffset
7757  COLORmarker = COLORtrace1
7758  Units = " V"
7759  if MarkerScale.get() == 2:
7760  MouseY = MouseCBV
7761  Yconv1 = float(GRH/10.0) / CH2pdvRange
7762  Yoffset1 = CHBOffset
7763  COLORmarker = COLORtrace2
7764  Units = " V"
7765  if MarkerScale.get() == 3:
7766  MouseY = MouseCAI
7767  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7768  Yoffset1 = CHAIOffset
7769  COLORmarker = COLORtrace3
7770  Units = " mA"
7771  if MarkerScale.get() == 4:
7772  MouseY = MouseCBI
7773  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7774  Yoffset1 = CHBIOffset
7775  COLORmarker = COLORtrace4
7776  Units = " mA"
7777  # Analog Mux settings
7778  if MarkerScale.get() == 5:
7779  MouseY = MouseMuxA
7780  Yconv1 = float(GRH/10.0) / CHMApdvRange
7781  Yoffset1 = CHBAOffset
7782  COLORmarker = COLORtrace2
7783  Units = " V"
7784  if MarkerScale.get() == 6:
7785  MouseY = MouseMuxB
7786  Yconv1 = float(GRH/10.0) / CHMBpdvRange
7787  Yoffset1 = CHBBOffset
7788  COLORmarker = COLORtrace6
7789  Units = " V"
7790  if MarkerScale.get() == 7:
7791  MouseY = MouseMuxC
7792  Yconv1 = float(GRH/10.0) / CHMCpdvRange
7793  Yoffset1 = CHBCOffset
7794  COLORmarker = COLORtrace7
7795  Units = " V"
7796  if MarkerScale.get() == 8:
7797  MouseY = MouseMuxD
7798  Yconv1 = float(GRH/10.0) / CHMDpdvRange
7799  Yoffset1 = CHBDOffset
7800  COLORmarker = COLORtrace4
7801  Units = " V"
7802 #
7803  if ShowTCur.get() > 0:
7804  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
7805  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7806  Tpoint = ((TCursor-X0L) * Tstep) + vt
7807  Tpoint = Tpoint/Mulx
7808  if Tpoint >= 1000:
7809  axis_value = Tpoint / 1000.0
7810  V_label = ' {0:.2f} '.format(axis_value) + " S"
7811  if Tpoint < 1000 and Tpoint >= 1:
7812  axis_value = Tpoint
7813  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7814  if Tpoint < 1:
7815  axis_value = Tpoint * 1000.0
7816  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7817  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7818  ca.create_text(TCursor, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7819  if ShowVCur.get() > 0:
7820  Dline = [X0L, VCursor, X0L+GRW, VCursor]
7821  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
7822  c1 = GRH / 2 + Y0T # fixed Y correction
7823  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
7824  V1String = ' {0:.3f} '.format(-yvolts)
7825  V_label = V1String + Units
7826  ca.create_text(X0L+GRW+2, VCursor, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7827  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
7828  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
7829  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
7830  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7831  ca.create_oval(MouseX-GridWidth.get(), MouseY-GridWidth.get(), MouseX+GridWidth.get(), MouseY+GridWidth.get(), outline=COLORtrigger, fill=COLORtrigger, width=GridWidth.get())
7832  Tpoint = ((MouseX-X0L) * Tstep) + vt
7833  Tpoint = Tpoint/Mulx
7834  if Tpoint >= 1000:
7835  axis_value = Tpoint / 1000.0
7836  V_label = ' {0:.2f} '.format(axis_value) + " S"
7837  if Tpoint < 1000 and Tpoint >= 1:
7838  axis_value = Tpoint
7839  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7840  if Tpoint < 1:
7841  axis_value = Tpoint * 1000.0
7842  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7843  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7844  ca.create_text(MouseX, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7845  Dline = [X0L, MouseY, X0L+GRW, MouseY]
7846  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7847  c1 = GRH / 2 + Y0T # fixed Y correction
7848  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7849  V1String = ' {0:.3f} '.format(-yvolts)
7850  V_label = V1String + Units
7851  ca.create_text(X0L+GRW+2, MouseY, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7852 #
7853  if MeasGateStatus.get() == 1:
7854  LeftGate = X0L + MeasGateLeft / Tstep
7855  RightGate = X0L + MeasGateRight / Tstep
7856  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
7857  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
7858  #
7859  # TString = ' {0:.2f} '.format(Tpoint)
7860  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7861  DT = (MeasGateRight-MeasGateLeft)/Mulx
7862  if DT == 0.0:
7863  DT = 1.0
7864  if DT >= 1000:
7865  axis_value = DT / 1000.0
7866  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
7867  if DT < 1000 and DT >= 1:
7868  axis_value = DT
7869  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
7870  if DT < 1:
7871  axis_value = DT * 1000.0
7872  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
7873  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
7874  DFreq = ' {0:.3f} '.format(1.0/DT)
7875  V_label = " Delta T" + DeltaT
7876  #V_label = V_label + Units
7877  V_label = V_label + ", Freq " + DFreq + " KHz"
7878  # place in upper left unless specified otherwise
7879  x = X0L + 5
7880  y = Y0T + 7
7881  Justify = 'w'
7882  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
7883  x = X0L + GRW - 5
7884  y = Y0T + 7
7885  Justify = 'e'
7886  if MarkerLoc == 'LL' or MarkerLoc == 'll':
7887  x = X0L + 5
7888  y = Y0T + GRH + 7 - (MarkerNum*10)
7889  Justify = 'w'
7890  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
7891  x = X0L + GRW - 5
7892  y = Y0T + GRH + 7
7893  Justify = 'e'
7894  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
7895  #
7896 #
7897  SmoothBool = SmoothCurves.get()
7898  # Write the traces if available
7899  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
7900  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
7901  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
7902  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
7903  if len(T2Vline) > 4: # Write the trace 2 if active
7904  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7905  if len(T2Iline) > 4:
7906  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7907  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
7908  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7909  if len(TMXline) > 4 : # Write X Math tace if active
7910  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7911  if len(TMYline) > 4 : # Write Y Math tace if active
7912  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7913  if MuxScreenStatus.get() == 1:
7914  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
7915  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7916  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
7917  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7918  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
7919  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7920  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
7921  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7922  if ShowRMA.get() == 1 and len(TMARline) > 4:
7923  ca.create_line(TMARline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7924  if ShowRMB.get() == 1 and len(TMBRline) > 4:
7925  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7926  if ShowRMC.get() == 1 and len(TMCRline) > 4:
7927  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7928  if ShowRMD.get() == 1 and len(TMDRline) > 4:
7929  ca.create_line(TMDRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7930  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
7931  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7932  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
7933  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7934  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
7935  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7936  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
7937  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7938  if ShowMath.get() == 1 and len(TMRline) > 4:
7939  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7940  if First_Slow_sweep == 1:
7941  # print(len(D0line),len(D1line), len(D2line), len(D3line))
7942  if D0.get() == 0:
7943  ca.create_line(D0line, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7944  if D1.get() == 0:
7945  ca.create_line(D1line, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7946  if D2.get() == 0:
7947  ca.create_line(D2line, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7948  if D3.get() == 0:
7949  ca.create_line(D3line, fill=COLORzeroline, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7950  # General information on top of the grid
7951  # Sweep information
7952  if session.continuous:
7953  sttxt = "Running Continuous"
7954  else:
7955  sttxt = "Running Discontinuous"
7956  if TRACEmodeTime.get() == 1:
7957  sttxt = sttxt + " Averaging"
7958  if ManualTrigger.get() == 1:
7959  sttxt = "Manual Trigger"
7960  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7961  sttxt = "Stopped"
7962  if ScreenTrefresh.get() == 1:
7963  sttxt = sttxt + " Persistance ON"
7964  # Delete text at bottom of screen
7965  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
7966  for n in de:
7967  ca.delete(n)
7968  # Delete text at top of screen
7969  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
7970  for n in de:
7971  ca.delete(n)
7972  if Roll_Mode.get() == 0:
7973  if LabelPlotText.get() > 0:
7974  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7975  else:
7976  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7977  else:
7978  if LabelPlotText.get() > 0:
7979  txt = PlotLabelText + " Rolling Sweep " + sttxt
7980  else:
7981  txt = "Device ID " + DevID[17:31] + " Rolling Sweep " + sttxt
7982  x = X0L+2
7983  y = 12
7984  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7985  # digital I/O indicators
7986  x2 = X0L + GRW
7987  BoxColor = "#808080" # gray
7988  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
7989  if D0.get() == 0 and D4.get() == 0:
7990  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7991  if Dval[0] == 1:
7992  BoxColor = "#00ff00" # 100% green
7993  elif Dval[0] == 0:
7994  BoxColor = "#ff0000" # 100% red
7995  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7996  else:
7997  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7998  if D1.get() == 0 and D5.get() == 0:
7999  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8000  if Dval[0] == 1:
8001  BoxColor = "#00ff00" # 100% green
8002  elif Dval[0] == 0:
8003  BoxColor = "#ff0000" # 100% red
8004  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8005  else:
8006  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8007  if D2.get() == 0 and D6.get() == 0:
8008  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8009  if Dval[0] == 1:
8010  BoxColor = "#00ff00" # 100% green
8011  elif Dval[0] == 0:
8012  BoxColor = "#ff0000" # 100% red
8013  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8014  else:
8015  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8016  if D3.get() == 0 and D7.get() == 0:
8017  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8018  if Dval[0] == 1:
8019  BoxColor = "#00ff00" # 100% green
8020  elif Dval[0] == 0:
8021  BoxColor = "#ff0000" # 100% red
8022  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8023  else:
8024  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8025  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
8026  # Time sweep information and view at information
8027  vx = TIMEdiv/Mulx
8028  if vx >= 1000:
8029  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
8030  if vx < 1000 and vx >= 1:
8031  txt = ' {0:.2f} '.format(vx) + " mS/div"
8032  if vx < 1:
8033  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
8034 
8035  txt = txt + " "
8036  #
8037  txt = txt + "View at "
8038  if abs(vt) >= 1000:
8039  txt = txt + str(int(vt / 1000.0)) + " S "
8040  if abs(vt) < 1000 and abs(vt) >= 1:
8041  txt = txt + str(int(vt)) + " mS "
8042  if abs(vt) < 1:
8043  txt = txt + str(int(vt * 1000.0)) + " uS "
8044  # print period and frequency of displayed channels
8045  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
8046  if ETSDisp.get() > 0:
8047  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
8048  else:
8049  if MeasGateStatus.get() == 1:
8050  if (MeasGateRight-MeasGateLeft) > 0:
8051  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
8052  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
8053  if Endsample <= hldn:
8054  Endsample = hldn + 2
8055  FindRisingEdge(VBuffA[hldn:Endsample],VBuffB[hldn:Endsample])
8056  else:
8057  FindRisingEdge(VBuffA,VBuffB)
8058  if ShowC1_V.get() == 1:
8059  if MeasAHW.get() == 1:
8060  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
8061  if MeasALW.get() == 1:
8062  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
8063  if MeasADCy.get() == 1:
8064  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8065  if MeasAPER.get() == 1:
8066  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
8067  if MeasAFREQ.get() == 1:
8068  txt = txt + " CA Freq = "
8069  ChaF = CHAfreq*Mulx
8070  if ChaF < 1000:
8071  V1String = ' {0:.1f} '.format(ChaF)
8072  txt = txt + str(V1String) + " Hz "
8073  if ChaF > 1000 and ChaF < 1000000:
8074  V1String = ' {0:.1f} '.format(ChaF/1000)
8075  txt = txt + str(V1String) + " KHz "
8076  if ChaF > 1000000:
8077  V1String = ' {0:.1f} '.format(ChaF/1000000)
8078  txt = txt + str(V1String) + " MHz "
8079  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8080  if ShowC2_V.get() == 1:
8081  if MeasBHW.get() == 1:
8082  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
8083  if MeasBLW.get() == 1:
8084  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
8085  if MeasBDCy.get() == 1:
8086  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8087  if MeasBPER.get() == 1:
8088  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
8089  if MeasBFREQ.get() == 1:
8090  txt = txt + " CB Freq = "
8091  ChaF = CHBfreq*Mulx
8092  if ChaF < 1000:
8093  V1String = ' {0:.1f} '.format(ChaF)
8094  txt = txt + str(V1String) + " Hz "
8095  if ChaF > 1000 and ChaF < 1000000:
8096  V1String = ' {0:.1f} '.format(ChaF/1000)
8097  txt = txt + str(V1String) + " KHz "
8098  if ChaF > 1000000:
8099  V1String = ' {0:.1f} '.format(ChaF/1000000)
8100  txt = txt + str(V1String) + " MHz "
8101  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8102  if MuxScreenStatus.get() == 0:
8103  if MeasPhase.get() == 1:
8104  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8105  if MeasDelay.get() == 1:
8106  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8107 
8108  x = X0L
8109  y = Y0T+GRH+int(2.5 *FontSize) # 20
8110  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8111  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
8112  MakeHistogram()
8113  txt = " "
8114  if ShowC1_V.get() == 1:
8115  # Channel A information
8116  if CHA_RC_HP.get() == 1:
8117  txt = "CHA: HP "
8118  else:
8119  txt = "CHA: "
8120  txt = txt + str(CH1pdvRange) + " V/div"
8121  if MeasDCV1.get() == 1:
8122  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8123  if MeasMaxV1.get() == 1:
8124  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8125  if MeasTopV1.get() == 1:
8126  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8127  if MeasMinV1.get() == 1:
8128  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8129  if MeasBaseV1.get() == 1:
8130  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
8131  if MeasMidV1.get() == 1:
8132  MidV1 = (MaxV1+MinV1)/2.0
8133  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8134  if MeasPPV1.get() == 1:
8135  PPV1 = MaxV1-MinV1
8136  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8137  if MeasRMSV1.get() == 1:
8138  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8139  if MeasRMSVA_B.get() == 1:
8140  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
8141  if MeasDiffAB.get() == 1:
8142  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
8143  if MeasUserA.get() == 1:
8144  try:
8145  TempValue = eval(UserAString)
8146  V1String = ' {0:.4f} '.format(TempValue)
8147  except:
8148  V1String = "####"
8149  txt = txt + UserALabel + " = " + V1String
8150  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
8151  txt = "CHA: "
8152  txt = txt + str(CH1IpdvRange) + " mA/div"
8153  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
8154  txt = txt + "CHA: "
8155  txt = txt + str(CH1IpdvRange) + " mA/div"
8156  if ShowC1_I.get() == 1:
8157  if MeasDCI1.get() == 1:
8158  V1String = ' {0:.2f} '.format(DCI1)
8159  txt = txt + " AvgI = " + V1String
8160  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8161  try:
8162  Resvalue = (DCV1/DCI1)*1000
8163  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8164  except:
8165  txt = txt + " Res = OverRange"
8166  if MeasMaxI1.get() == 1:
8167  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8168  if MeasMinI1.get() == 1:
8169  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8170  if MeasMidI1.get() == 1:
8171  MidI1 = (MaxI1+MinI1)/2.0
8172  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8173  if MeasPPI1.get() == 1:
8174  PPI1 = MaxI1-MinI1
8175  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8176  if MeasRMSI1.get() == 1:
8177  txt = txt + " RMS = " + ' {0:.2f} '.format(SI1)
8178 
8179  x = X0L
8180  y = Y0T+GRH+(4*FontSize) # 32
8181  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8182  txt= " "
8183  # Channel B information
8184  if MuxScreenStatus.get() == 1:
8185  txt = "CHB-Mux: "
8186  if Show_CBA.get() > 0:
8187  FindRisingEdge(VBuffA,VBuffMA)
8188  elif Show_CBB.get() > 0:
8189  FindRisingEdge(VBuffA,VBuffMB)
8190  elif Show_CBC.get() > 0:
8191  FindRisingEdge(VBuffA,VBuffMC)
8192  elif Show_CBD.get() > 0:
8193  FindRisingEdge(VBuffA,VBuffMD)
8194  if MeasPhase.get() == 1:
8195  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8196  if MeasDelay.get() == 1:
8197  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8198  if MeasUserB.get() == 1:
8199  try:
8200  TempValue = eval(UserBString)
8201  V1String = ' {0:.4f} '.format(TempValue)
8202  except:
8203  V1String = "####"
8204  txt = txt + UserBLabel + " = " + V1String
8205  if ShowC2_V.get() == 1:
8206  if CHB_RC_HP.get() == 1:
8207  txt = "CHB: HP "
8208  else:
8209  txt = "CHB: "
8210  txt = txt + str(CH2pdvRange) + " V/div"
8211  if MeasDCV2.get() == 1:
8212  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8213  if MeasMaxV2.get() == 1:
8214  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8215  if MeasTopV2.get() == 1:
8216  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8217  if MeasMinV2.get() == 1:
8218  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8219  if MeasBaseV2.get() == 1:
8220  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
8221  if MeasMidV2.get() == 1:
8222  MidV2 = (MaxV2+MinV2)/2.0
8223  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8224  if MeasPPV2.get() == 1:
8225  PPV2 = MaxV2-MinV2
8226  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8227  if MeasRMSV2.get() == 1:
8228  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8229  if MeasDiffBA.get() == 1:
8230  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
8231  if MeasUserB.get() == 1:
8232  try:
8233  TempValue = eval(UserBString)
8234  V1String = ' {0:.4f} '.format(TempValue)
8235  except:
8236  V1String = "####"
8237  txt = txt + UserBLabel + " = " + V1String
8238  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
8239  txt = "CHB: "
8240  txt = txt + str(CH2IpdvRange) + " mA/div"
8241  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
8242  txt = txt + "CHB: "
8243  txt = txt + str(CH2IpdvRange) + " mA/div"
8244  if ShowC2_I.get() == 1:
8245  if MeasDCI2.get() == 1:
8246  V1String = ' {0:.2f} '.format(DCI2)
8247  txt = txt + " AvgI = " + V1String
8248  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8249  try:
8250  Resvalue = (DCV2/DCI2)*1000
8251  R1String = ' {0:.1f} '.format(Resvalue)
8252  txt = txt + " Res = " + R1String
8253  except:
8254  txt = txt + " Res = OverRange"
8255  if MeasMaxI2.get() == 1:
8256  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8257  if MeasMinI2.get() == 1:
8258  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8259  if MeasMidI2.get() == 1:
8260  MidI2 = (MaxI2+MinI2)/2.0
8261  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8262  if MeasPPI2.get() == 1:
8263  PPI2 = MaxI2-MinI2
8264  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8265  if MeasRMSI2.get() == 1:
8266  txt = txt + " RMS = " + ' {0:.2f} '.format(SI2)
8267 
8268  x = X0L
8269  y = Y0T+GRH+int(5.5*FontSize) # 44
8270  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8271 
8273  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY # active trave lines
8274  global Tmathline, TMRline, XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
8275  global X0LXY # Left top X value
8276  global Y0TXY # Left top Y value
8277  global GRWXY # Screenwidth
8278  global GRHXY # Screenheight
8279  global FontSize, LabelPlotText, PlotLabelText
8280  global XYca, MouseX, MouseY, MouseWidget
8281  global ShowXCur, ShowYCur, XCursor, YCursor
8282  global SHOWsamples # Number of samples in data record
8283  global ShowMath, MathUnits, MathXUnits, MathYUnits
8284  global Xsignal, MathAxis, MathXAxis, MathYAxis
8285  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMY, YsignalMX
8286  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
8287  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
8288  global CHAsbxy # spinbox Index for channel 1 V
8289  global CHBsbxy # spinbox Index for channel 2 V
8290  global CHAOffset # Offset value for channel 1 V
8291  global CHBOffset # Offset value for channel 2 V
8292  global CHAIsbxy # spinbox Index for channel 1 I
8293  global CHBIsbxy # spinbox Index for channel 2 I
8294  global CHAIOffset # Offset value for channel 1 I
8295  global CHBIOffset # Offset value for channel 2 I
8296  global TMpdiv # Array with time / div values in ms
8297  global TMsb # Time per div spin box variable
8298  global TIMEdiv # current spin box value
8299  global SAMPLErate
8300  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
8301  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace6, COLORtrace7 # The colors
8302  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
8303  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6, COLORtraceR7
8304  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
8305  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
8306  global ScreenXYrefresh, SmoothCurves
8307  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
8308  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
8309  global SV1, SI1, SV2, SI2, CHABphase
8310  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
8311  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
8312  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
8313  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
8314  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
8315  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
8316  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
8317  global AWGAShape, AWGBShape
8318  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
8319  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
8320  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
8321  global DacScreenStatus, DigScreenStatus
8322  global D0, D1, D2, D3, D4, D5, D6, D7
8323  global DevID, devx, MarkerNum, MarkerScale
8324  global HozPoss, HozPossentry
8325  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
8326  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
8327  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
8328  #
8329  Ymin = Y0TXY # Minimum position of screen grid (top)
8330  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
8331  RightOffset = FontSize * 3
8332  LeftOffset = int(FontSize/2)
8333  try:
8334  InOffA = float(eval(CHAVOffsetEntry.get()))
8335  except:
8336  CHAVOffsetEntry.delete(0,END)
8337  CHAVOffsetEntry.insert(0, InOffA)
8338  try:
8339  InGainA = float(eval(CHAVGainEntry.get()))
8340  except:
8341  CHAVGainEntry.delete(0,END)
8342  CHAVGainEntry.insert(0, InGainA)
8343  try:
8344  InOffB = float(eval(CHBVOffsetEntry.get()))
8345  except:
8346  CHBVOffsetEntry.delete(0,END)
8347  CHBVOffsetEntry.insert(0, InOffB)
8348  try:
8349  InGainB = float(eval(CHBVGainEntry.get()))
8350  except:
8351  CHBVGainEntry.delete(0,END)
8352  CHBVGainEntry.insert(0, InGainB)
8353 #
8354  try:
8355  CH1pdvRange = float(eval(CHAsbxy.get()))
8356  except:
8357  CHAsbxy.delete(0,END)
8358  CHAsbxy.insert(0, CH1pdvRange)
8359  try:
8360  CH2pdvRange = float(eval(CHBsbxy.get()))
8361  except:
8362  CHBsbxy.delete(0,END)
8363  CHBsbxy.insert(0, CH2pdvRange)
8364  try:
8365  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8366  except:
8367  CHAIsbxy.delete(0,END)
8368  CHAIsbxy.insert(0, CH1IpdvRange)
8369  try:
8370  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8371  except:
8372  CHBIsbxy.delete(0,END)
8373  CHBIsbxy.insert(0, CH2IpdvRange)
8374  # get the vertical offsets
8375  try:
8376  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8377  except:
8378  CHAVPosEntryxy.delete(0,END)
8379  CHAVPosEntryxy.insert(0, CHAOffset)
8380  try:
8381  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8382  except:
8383  CHAIPosEntryxy.delete(0,END)
8384  CHAIPosEntryxy.insert(0, CHAIOffset)
8385  try:
8386  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8387  except:
8388  CHBVPosEntry.delete(0,END)
8389  CHBVPosEntry.insert(0, CHBOffset)
8390  try:
8391  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8392  except:
8393  CHBIPosEntryxy.delete(0,END)
8394  CHBIPosEntryxy.insert(0, CHBIOffset)
8395  # prevent divide by zero error
8396  if CH1pdvRange < 0.001:
8397  CH1pdvRange = 0.001
8398  if CH2pdvRange < 0.001:
8399  CH2pdvRange = 0.001
8400  if CH1IpdvRange < 0.05:
8401  CH1IpdvRange = 0.05
8402  if CH2IpdvRange < 0.05:
8403  CH2IpdvRange = 0.05
8404  # If drawing histograms adjust offset based on range such that bottom grid is zero
8405  if Xsignal.get() == 6:
8406  CHAIOffset = 5 * CH1IpdvRange
8407  if Xsignal.get() == 7:
8408  CHBIOffset = 5 * CH2IpdvRange
8409  if ScreenXYrefresh.get() == 0:
8410  # Delete all items on the screen
8411  MarkerNum = 0
8412  XYca.delete(ALL) # remove all items
8413  # Draw horizontal grid lines
8414  i = 0
8415  x1 = X0LXY
8416  x2 = X0LXY + GRWXY
8417  mg_siz = GRWXY/10.0
8418  mg_inc = mg_siz/5.0
8419  while (i < 11):
8420  y = Y0TXY + i * GRHXY/10.0
8421  Dline = [x1,y,x2,y]
8422  if i == 5:
8423  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8424  k = 0
8425  while (k < 10):
8426  l = 1
8427  while (l < 5):
8428  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8429  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8430  l = l + 1
8431  k = k + 1
8432  else:
8433  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8434  if YsignalIA.get() == 1 or Xsignal.get() == 6:
8435  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8436  Iaxis_label = str(round(Iaxis_value, 3))
8437  XYca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8438  if YsignalIB.get() == 1 or Xsignal.get() == 7:
8439  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8440  Iaxis_label = str(round(Iaxis_value, 3))
8441  XYca.create_text(x2+RightOffset, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize ))
8442  if YsignalVA.get() == 1:
8443  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8444  Vaxis_label = str(round(Vaxis_value, 3))
8445  XYca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8446  if YsignalVB.get() == 1:
8447  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8448  Vaxis_label = str(round(Vaxis_value, 3))
8449  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
8450  if YsignalM.get() == 1:
8451  TempCOLOR = COLORtrace5
8452  if MathTrace.get() == 2:
8453  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8454  elif MathTrace.get() == 3:
8455  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8456  else:
8457  if MathAxis == "V-A":
8458  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8459  TempCOLOR = COLORtrace1
8460  elif MathAxis == "V-B":
8461  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8462  TempCOLOR = COLORtrace2
8463  elif MathAxis == "I-A":
8464  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8465  TempCOLOR = COLORtrace3
8466  elif MathAxis == "I-B":
8467  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8468  TempCOLOR = COLORtrace4
8469  else:
8470  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8471  Vaxis_label = str(round(Vaxis_value, 3))
8472  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8473  if YsignalMX.get() == 1:
8474  TempCOLOR = COLORtrace6
8475  if MathXAxis == "V-A":
8476  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8477  TempCOLOR = COLORtrace1
8478  elif MathXAxis == "V-B":
8479  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8480  TempCOLOR = COLORtrace2
8481  elif MathXAxis == "I-A":
8482  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8483  TempCOLOR = COLORtrace3
8484  elif MathXAxis == "I-B":
8485  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8486  TempCOLOR = COLORtrace4
8487  else:
8488  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8489  Vaxis_label = str(round(Vaxis_value, 3))
8490  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8491  if YsignalMY.get() == 1:
8492  TempCOLOR = COLORtrace7
8493  if MathYAxis == "V-A":
8494  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8495  TempCOLOR = COLORtrace1
8496  elif MathYAxis == "V-B":
8497  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8498  TempCOLOR = COLORtrace2
8499  elif MathYAxis == "I-A":
8500  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8501  TempCOLOR = COLORtrace3
8502  elif MathYAxis == "I-B":
8503  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8504  TempCOLOR = COLORtrace4
8505  else:
8506  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8507  Vaxis_label = str(round(Vaxis_value, 3))
8508  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8509  i = i + 1
8510  # Draw vertical grid lines
8511  i = 0
8512  y1 = Y0TXY
8513  y2 = Y0TXY + GRHXY
8514  mg_siz = GRHXY/10.0
8515  mg_inc = mg_siz/5.0
8516  #
8517  while (i < 11):
8518  x = X0LXY + i * GRWXY/10.0
8519  Dline = [x,y1,x,y2]
8520  if (i == 5):
8521  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8522  k = 0
8523  while (k < 10):
8524  l = 1
8525  while (l < 5):
8526  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8527  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8528  l = l + 1
8529  k = k + 1
8530  if Xsignal.get() == 1 or Xsignal.get() == 6: #
8531  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8532  Vaxis_label = str(round(Vaxis_value, 3))
8533  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8534  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8535  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8536  Vaxis_label = str(round(Vaxis_value, 3))
8537  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8538  elif Xsignal.get() == 2:
8539  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8540  Iaxis_label = str(round(Iaxis_value, 3))
8541  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8542  elif Xsignal.get() == 4:
8543  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8544  Iaxis_label = str(round(Iaxis_value, 3))
8545  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8546  elif Xsignal.get() == 5:
8547  TempCOLOR = COLORtrace5
8548  if MathTrace.get() == 2:
8549  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8550  elif MathTrace.get() == 3:
8551  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8552  else:
8553  if MathXAxis == "V-A":
8554  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8555  TempCOLOR = COLORtrace1
8556  elif MathXAxis == "V-B":
8557  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8558  TempCOLOR = COLORtrace2
8559  elif MathXAxis == "I-A":
8560  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8561  TempCOLOR = COLORtrace3
8562  elif MathXAxis == "I-B":
8563  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8564  TempCOLOR = COLORtrace4
8565  else:
8566  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8567  TempCOLOR = COLORtrace5
8568  Vaxis_label = str(round(Vaxis_value, 3))
8569  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8570  else:
8571  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8572  if Xsignal.get() == 1 or Xsignal.get() == 6:
8573  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8574  Vaxis_label = str(round(Vaxis_value, 3))
8575  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8576  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8577  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8578  Vaxis_label = str(round(Vaxis_value, 3))
8579  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8580  elif Xsignal.get() == 2:
8581  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8582  Iaxis_label = str(round(Iaxis_value, 3))
8583  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8584  elif Xsignal.get() == 4:
8585  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8586  Iaxis_label = str(round(Iaxis_value, 3))
8587  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8588  elif Xsignal.get() == 5:
8589  TempCOLOR = COLORtrace5
8590  if MathTrace.get() == 2:
8591  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8592  elif MathTrace.get() == 3:
8593  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8594  else:
8595  if MathXAxis == "V-A":
8596  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8597  TempCOLOR = COLORtrace1
8598  elif MathXAxis == "V-B":
8599  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8600  TempCOLOR = COLORtrace2
8601  elif MathXAxis == "I-A":
8602  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8603  TempCOLOR = COLORtrace3
8604  elif MathXAxis == "I-B":
8605  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8606  TempCOLOR = COLORtrace4
8607  else:
8608  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8609  Vaxis_label = str(round(Vaxis_value, 3))
8610  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8611  i = i + 1
8612 # Draw traces
8613 # Avoid writing lines with 1 coordinate
8614  if YsignalVA.get() == 1:
8615  if len(XYlineVA) > 4:
8616  XYca.create_line(XYlineVA, fill=COLORtrace1, width=TRACEwidth.get())
8617  if YsignalIA.get() == 1:
8618  if len(XYlineIA) > 4:
8619  XYca.create_line(XYlineIA, fill=COLORtrace3, width=TRACEwidth.get())
8620  if YsignalVB.get() == 1:
8621  if len(XYlineVB) > 4:
8622  XYca.create_line(XYlineVB, fill=COLORtrace2, width=TRACEwidth.get())
8623  if YsignalIB.get() == 1:
8624  if len(XYlineIB) > 4:
8625  XYca.create_line(XYlineIB, fill=COLORtrace4, width=TRACEwidth.get())
8626  if YsignalM.get() == 1: # or Ysignal.get() == 5:
8627  if len(XYlineM) > 4:
8628  XYca.create_line(XYlineM, fill=COLORtrace5, width=TRACEwidth.get())
8629  if YsignalMX.get() == 1:
8630  if len(XYlineMX) > 4:
8631  XYca.create_line(XYlineMX, fill=COLORtrace6, width=TRACEwidth.get())
8632  if YsignalMY.get() == 1:
8633  if len(XYlineMY) > 4:
8634  XYca.create_line(XYlineMY, fill=COLORtrace7, width=TRACEwidth.get())
8635  if len(XYRlineVA) > 4 and XYRefAV.get() == 1:
8636  XYca.create_line(XYRlineVA, fill=COLORtraceR1, width=TRACEwidth.get())
8637  if len(XYRlineVB) > 4 and XYRefBV.get() == 1:
8638  XYca.create_line(XYRlineVB, fill=COLORtraceR2, width=TRACEwidth.get())
8639  if len(XYRlineIA) > 4 and XYRefAI.get() == 1:
8640  XYca.create_line(XYRlineIA, fill=COLORtraceR3, width=TRACEwidth.get())
8641  if len(XYRlineIB) > 4 and XYRefBI.get() == 1:
8642  XYca.create_line(XYRlineIB, fill=COLORtraceR4, width=TRACEwidth.get())
8643  if len(XYRlineM) > 4 and XYRefM.get() == 1:
8644  XYca.create_line(XYRlineM, fill=COLORtraceR5, width=TRACEwidth.get())
8645  if len(XYRlineMX) > 4 and XYRefMX.get() == 1:
8646  XYca.create_line(XYRlineMX, fill=COLORtraceR6, width=TRACEwidth.get())
8647  if len(XYRlineMY) > 4 and XYRefMY.get() == 1:
8648  XYca.create_line(XYRlineMY, fill=COLORtraceR7, width=TRACEwidth.get())
8649 # Draw Histogram Traces
8650  if Xsignal.get() == 6:
8651  MakeHistogram()
8652  b = 0
8653  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8654  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
8655  y1 = Y0TXY + GRHXY
8656  # print Yconv1, y1
8657  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8658  while b < 4999: #
8659  if HistAsPercent == 1: # convert to percent of total sample count
8660  ylo = float(HBuffA[0][b]) / len(VBuffA)
8661  ylo = ylo * 100.0
8662  else:
8663  ylo = HBuffA[0][b] #
8664  ylo = int(y1 - (Yconv1 * ylo))
8665  if ylo > Ymax:
8666  ylo = Ymax
8667  if ylo < Ymin:
8668  ylo = Ymin
8669  xlo = HBuffA[1][b] - CHAOffset
8670  xlo = int(c2 + Xconv1 * xlo)
8671  Dline = [xlo,y1,xlo,ylo]
8672  XYca.create_line(Dline, fill=COLORtrace1)
8673  b = b + 1
8674  if Xsignal.get() == 7:
8675  MakeHistogram()
8676  b = 0
8677  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8678  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
8679  y1 = Y0TXY + GRHXY
8680  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8681  while b < 4999: #
8682  if HistAsPercent == 1: # convert to percent
8683  ylo = float(HBuffB[0][b]) / len(VBuffB)
8684  ylo = ylo * 100.0
8685  else:
8686  ylo = HBuffB[0][b]
8687  ylo = int(y1 - Yconv1 * ylo)
8688  if ylo > Ymax:
8689  ylo = Ymax
8690  if ylo < Ymin:
8691  ylo = Ymin
8692  xlo = HBuffB[1][b] - CHBOffset
8693  xlo = int(c2 + Xconv1 * xlo)
8694  Dline = [xlo,y1,xlo,ylo]
8695  XYca.create_line(Dline, fill=COLORtrace2)
8696  b = b + 1
8697 # Draw X - Y Cursor lines if required
8698  COLORXmarker = COLORtrace1
8699  COLORYmarker = COLORtrace2
8700  if Xsignal.get() == 1 or Xsignal.get() == 6:
8701  Xconv1 = float(GRWXY/10) / CH1pdvRange
8702  Xoffset1 = CHAOffset
8703  COLORXmarker = COLORtrace1
8704  X_label = " V"
8705  if Xsignal.get() == 2:
8706  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8707  Xoffset1 = CHAIOffset
8708  COLORXmarker = COLORtrace3
8709  X_label = " mA"
8710  if Xsignal.get() == 3 or Xsignal.get() == 7:
8711  Xconv1 = float(GRWXY/10) / CH2pdvRange
8712  Xoffset1 = CHBOffset
8713  COLORXmarker = COLORtrace2
8714  X_label = " V"
8715  if Xsignal.get() == 4:
8716  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8717  Xoffset1 = CHBIOffset
8718  COLORmarker = COLORtrace4
8719  X_label = " mA"
8720  if Xsignal.get() == 5:
8721  X_label = MathXUnits
8722  if MathXAxis == "V-A":
8723  Xconv1 = float(GRWXY/10) / CH1pdvRange
8724  Xoffset1 = CHAOffset
8725  COLORXmarker = COLORtrace1
8726  elif MathXAxis == "V-B":
8727  Xconv1 = float(GRWXY/10) / CH2pdvRange
8728  Xoffset1 = CHBOffset
8729  COLORXmarker = COLORtrace2
8730  elif MathXAxis == "I-A":
8731  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8732  Xoffset1 = CHAIOffset
8733  COLORXmarker = COLORtrace3
8734  elif MathXAxis == "I-B":
8735  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8736  Xoffset1 = CHBIOffset
8737  COLORXmarker = COLORtrace4
8738  else:
8739  Xconv1 = float(GRWXY/10) / CH1pdvRange
8740  Xoffset1 = CHAOffset
8741  COLORXmarker = COLORtrace1
8742 #
8743  if YsignalVA.get() == 1 or YsignalM.get() == 1:
8744  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8745  Yoffset1 = CHAOffset
8746  COLORYmarker = COLORtrace1
8747  Y_label = " V"
8748  if YsignalIA.get() == 1:
8749  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8750  Yoffset1 = CHAIOffset
8751  COLORYmarker = COLORtrace3
8752  Y_label = " mA"
8753  if YsignalVB.get() == 1 or YsignalM.get() == 1:
8754  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8755  Yoffset1 = CHBOffset
8756  COLORYmarker = COLORtrace2
8757  Y_label = " V"
8758  if YsignalIB.get() == 1:
8759  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8760  Yoffset1 = CHBIOffset
8761  COLORYmarker = COLORtrace4
8762  Y_label = " mA"
8763  if YsignalM.get() == 1 or YsignalMX.get() == 1 or YsignalMY.get() == 1:
8764  Y_label = MathYUnits
8765  if MathYAxis == "V-A":
8766  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8767  Yoffset1 = CHAOffset
8768  COLORYmarker = COLORtrace1
8769  elif MathYAxis == "V-B":
8770  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8771  Yoffset1 = CHBOffset
8772  COLORYmarker = COLORtrace2
8773  elif MathYAxis == "I-A":
8774  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8775  Yoffset1 = CHAIOffset
8776  COLORYmarker = COLORtrace3
8777  elif MathYAxis == "I-B":
8778  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8779  Yoffset1 = CHBIOffset
8780  COLORYmarker = COLORtrace4
8781  else:
8782  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8783  Yoffset1 = CHAOffset
8784  COLORYmarker = COLORtrace1
8785  if ShowXCur.get() > 0:
8786  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
8787  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8788  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8789  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
8790  XString = ' {0:.3f} '.format(xvolts)
8791  V_label = XString + X_label
8792  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8793  if ShowYCur.get() > 0:
8794  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
8795  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8796  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
8797  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
8798  V1String = ' {0:.3f} '.format(-yvolts)
8799  V_label = V1String + Y_label
8800  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8801  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
8802  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
8803  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
8804  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8805  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8806  xvolts = Xoffset1 - ((c1-MouseX)/Xconv1) # XCursor
8807  XString = ' {0:.3f} '.format(xvolts)
8808  V_label = XString + X_label
8809  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8810  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
8811  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8812  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
8813  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
8814  V1String = ' {0:.3f} '.format(-yvolts)
8815  V_label = V1String + Y_label
8816  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8817 #
8818 # General information on top of the grid
8819 # Sweep information
8820  sttxt = "Running"
8821  if TRACEmodeTime.get() == 1:
8822  sttxt = sttxt + " Averaging"
8823  if ManualTrigger.get() == 1:
8824  sttxt = "Manual Trigger"
8825  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
8826  sttxt = "Stopped"
8827  if ScreenXYrefresh.get() == 1:
8828  sttxt = sttxt + " Persistance ON"
8829  # Delete text at bottom of screen
8830  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
8831  for n in de:
8832  XYca.delete(n)
8833  # Delete text at top of screen
8834  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
8835  for n in de:
8836  XYca.delete(n)
8837  if LabelPlotText.get() > 0:
8838  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8839  else:
8840  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8841  x = X0LXY
8842  y = 12
8843  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8844  # digital I/O indicators
8845  x2 = X0LXY + GRWXY
8846  BoxColor = "#808080" # gray
8847  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
8848  if D0.get() == 0 and D4.get() == 0:
8849  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
8850  if Dval[0] == 1:
8851  BoxColor = "#00ff00" # 100% green
8852  elif Dval[0] == 0:
8853  BoxColor = "#ff0000" # 100% red
8854  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
8855  else:
8856  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
8857  if D1.get() == 0 and D5.get() == 0:
8858  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8859  if Dval[0] == 1:
8860  BoxColor = "#00ff00" # 100% green
8861  elif Dval[0] == 0:
8862  BoxColor = "#ff0000" # 100% red
8863  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8864  else:
8865  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8866  if D2.get() == 0 and D6.get() == 0:
8867  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8868  if Dval[0] == 1:
8869  BoxColor = "#00ff00" # 100% green
8870  elif Dval[0] == 0:
8871  BoxColor = "#ff0000" # 100% red
8872  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8873  else:
8874  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8875  if D3.get() == 0 and D7.get() == 0:
8876  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8877  if Dval[0] == 1:
8878  BoxColor = "#00ff00" # 100% green
8879  elif Dval[0] == 0:
8880  BoxColor = "#ff0000" # 100% red
8881  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8882  else:
8883  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8884  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
8885  # print period and frequency of displayed channels
8886  txt = " "
8887  if Xsignal.get() == 1 or Xsignal.get() == 3:
8888  FindRisingEdge(VBuffA, VBuffB)
8889  if Xsignal.get() == 1:
8890  if MeasAHW.get() == 1:
8891  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
8892  if MeasALW.get() == 1:
8893  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
8894  if MeasADCy.get() == 1:
8895  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8896  if MeasAPER.get() == 1:
8897  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
8898  if MeasAFREQ.get() == 1:
8899  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8900  if Xsignal.get() == 3:
8901  if MeasBHW.get() == 1:
8902  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
8903  if MeasBLW.get() == 1:
8904  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
8905  if MeasBDCy.get() == 1:
8906  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8907  if MeasBPER.get() == 1:
8908  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
8909  if MeasBFREQ.get() == 1:
8910  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8911  if MeasPhase.get() == 1:
8912  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8913 
8914  x = X0LXY
8915  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
8916  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8917  txt = " "
8918  if Xsignal.get() == 1 or YsignalVA.get() == 1 or Xsignal.get() == 6:
8919  # Channel A information
8920  txt = "CHA: "
8921  txt = txt + str(CH1pdvRange) + " V/div"
8922  if MeasDCV1.get() == 1:
8923  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8924  if MeasMaxV1.get() == 1:
8925  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8926  if MeasTopV1.get() == 1:
8927  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8928  if MeasMinV1.get() == 1:
8929  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8930  if MeasBaseV1.get() == 1:
8931  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
8932  if MeasMidV1.get() == 1:
8933  MidV1 = (MaxV1+MinV1)/2
8934  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8935  if MeasPPV1.get() == 1:
8936  PPV1 = MaxV1-MinV1
8937  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8938  if MeasRMSV1.get() == 1:
8939  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8940  if MeasUserA.get() == 1:
8941  try:
8942  TempValue = eval(UserAString)
8943  V1String = ' {0:.4f} '.format(TempValue)
8944  except:
8945  V1String = "####"
8946  txt = txt + UserALabel + " = " + V1String
8947  if Xsignal.get() == 2:
8948  txt = "CHA: "
8949  txt = txt + str(CH1IpdvRange) + " mA/div"
8950  elif (Xsignal.get() == 2):
8951  txt = txt + "CHA: "
8952  txt = txt + str(CH1IpdvRange) + " mA/div"
8953  if Xsignal.get() == 2 or YsignalIA.get() == 1:
8954  if MeasDCI1.get() == 1:
8955  V1String = ' {0:.2f} '.format(DCI1)
8956  txt = txt + " AvgI = " + V1String
8957  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8958  try:
8959  Resvalue = (DCV1/DCI1)*1000
8960  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8961  except:
8962  txt = txt + " Res = OverRange"
8963  if MeasMaxI1.get() == 1:
8964  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8965  if MeasMinI1.get() == 1:
8966  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8967  if MeasMidI1.get() == 1:
8968  MidI1 = (MaxI1+MinI1)/2
8969  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8970  if MeasPPI1.get() == 1:
8971  PPI1 = MaxI1-MinI1
8972  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8973  if MeasRMSI1.get() == 1:
8974  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
8975 
8976  x = X0LXY
8977  y = Y0TXY+GRHXY+int(4*FontSize) # 32
8978  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8979  txt= " "
8980  # Channel B information
8981  if Xsignal.get() == 3 or YsignalVB.get() == 1 or Xsignal.get() == 7:
8982  txt = "CHB: "
8983  txt = txt + str(CH2pdvRange) + " V/div"
8984  if MeasDCV2.get() == 1:
8985  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8986  if MeasMaxV2.get() == 1:
8987  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8988  if MeasTopV2.get() == 1:
8989  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8990  if MeasMinV2.get() == 1:
8991  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8992  if MeasBaseV2.get() == 1:
8993  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
8994  if MeasMidV2.get() == 1:
8995  MidV2 = (MaxV2+MinV2)/2
8996  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8997  if MeasPPV2.get() == 1:
8998  PPV2 = MaxV2-MinV2
8999  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
9000  if MeasRMSV2.get() == 1:
9001  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
9002  if MeasUserB.get() == 1:
9003  try:
9004  TempValue = eval(UserBString)
9005  V1String = ' {0:.4f} '.format(TempValue)
9006  except:
9007  V1String = "####"
9008  txt = txt + UserBLabel + " = " + V1String
9009  if Xsignal.get() == 4:
9010  txt = "CHB: "
9011  txt = txt + str(CH2IpdvRange) + " mA/div"
9012  elif Xsignal.get() == 4:
9013  txt = txt + "CHB: "
9014  txt = txt + str(CH2IpdvRange) + " mA/div"
9015  if Xsignal.get() == 4 or YsignalIB.get() == 1:
9016  if MeasDCI2.get() == 1:
9017  V1String = ' {0:.2f} '.format(DCI2)
9018  txt = txt + " AvgI = " + V1String
9019  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
9020  try:
9021  Resvalue = (DCV2/DCI2)*1000
9022  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
9023  except:
9024  txt = txt + " Res = OverRange"
9025  if MeasMaxI2.get() == 1:
9026  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
9027  if MeasMinI2.get() == 1:
9028  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
9029  if MeasMidI2.get() == 1:
9030  MidI2 = (MaxI2+MinI2)/2
9031  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
9032  if MeasPPI2.get() == 1:
9033  PPI2 = MaxI2-MinI2
9034  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
9035  if MeasRMSI2.get() == 1:
9036  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
9037 
9038  x = X0LXY
9039  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
9040  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
9041 #
9043  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9044 
9045  if MarkerScale.get() != 1:
9046  MarkerScale.set(1)
9047  CHAlab.config(style="Rtrace1.TButton")
9048  CHBlab.config(style="Strace2.TButton")
9049  CHAIlab.config(style="Strace3.TButton")
9050  CHBIlab.config(style="Strace4.TButton")
9051  else:
9052  MarkerScale.set(0)
9053 #
9055  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9056 
9057  if MarkerScale.get() != 3:
9058  MarkerScale.set(3)
9059  CHAlab.config(style="Strace1.TButton")
9060  CHBlab.config(style="Strace2.TButton")
9061  CHAIlab.config(style="Rtrace3.TButton")
9062  CHBIlab.config(style="Strace4.TButton")
9063  else:
9064  MarkerScale.set(0)
9065 
9067  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9068 
9069  if MarkerScale.get() != 2:
9070  MarkerScale.set(2)
9071  CHAlab.config(style="Strace1.TButton")
9072  CHBlab.config(style="Rtrace2.TButton")
9073  CHAIlab.config(style="Strace3.TButton")
9074  CHBIlab.config(style="Strace4.TButton")
9075  else:
9076  MarkerScale.set(0)
9077 
9079  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9080 
9081  if MarkerScale.get() != 3:
9082  MarkerScale.set(4)
9083  CHAlab.config(style="Strace1.TButton")
9084  CHBlab.config(style="Strace2.TButton")
9085  CHAIlab.config(style="Strace3.TButton")
9086  CHBIlab.config(style="Rtrace4.TButton")
9087  else:
9088  MarkerScale.set(0)
9089 #
9091  global MarkerXYScale, CHAxylab, CHBxylab
9092 
9093  MarkerXYScale.set(1)
9094  CHAxylab.config(style="Rtrace1.TButton")
9095  CHBxylab.config(style="Strace2.TButton")
9096 
9098  global MarkerXYScale, CHAxylab, CHBxylab
9099 
9100  MarkerXYScale.set(2)
9101  CHBxylab.config(style="Rtrace2.TButton")
9102  CHAxylab.config(style="Strace1.TButton")
9103 #
9105  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
9106 
9107  TCursor = event.x
9108  VCursor = event.y
9109  if RUNstatus.get() == 0:
9111  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
9112 
9114  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
9115  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
9116 
9117  ShiftKeyDwn = event.state & 1
9118  if event.widget == ca:
9119  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
9120  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
9121  # respond to Linux or Windows wheel event
9122  if event.num == 5 or event.delta == -120:
9123  TCursor -= 1
9124  if event.num == 4 or event.delta == 120:
9125  TCursor += 1
9126  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
9127  # respond to Linux or Windows wheel event
9128  if event.num == 5 or event.delta == -120:
9129  VCursor += 1
9130  if event.num == 4 or event.delta == 120:
9131  VCursor -= 1
9132 
9136  else:
9137  if MeasGateStatus.get() == 1:
9138  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
9139  if ShiftKeyDwn == 0:
9140  if event.num == 5 or event.delta == -120:
9141  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
9142  if event.num == 4 or event.delta == 120:
9143  MeasGateLeft = MeasGateLeft + (100 * Tstep)
9144  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
9145  if ShiftKeyDwn == 1:
9146  if event.num == 5 or event.delta == -120:
9147  MeasGateRight = MeasGateRight + (-100 * Tstep)
9148  if event.num == 4 or event.delta == 120:
9149  MeasGateRight = MeasGateRight + (100 * Tstep)
9150  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
9151  try:
9152  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
9153  except:
9154  donothing()
9155  if RUNstatus.get() == 0:
9157 
9158 def onCanvasUpArrow(event):
9159  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
9160 
9161  shift_key = event.state & 1
9162  if event.widget == ca:
9163  if ShowVCur.get() > 0 and shift_key == 0:
9164  VCursor = VCursor - 1
9165  elif ShowVCur.get() > 0 and shift_key == 1:
9166  VCursor = VCursor - 5
9167  if RUNstatus.get() == 0:
9169  try:
9170  if event.widget == XYca:
9171  if ShowYCur.get() > 0 and shift_key == 0:
9172  YCursor = YCursor - 1
9173  elif ShowYCur.get() > 0 and shift_key == 1:
9174  YCursor = YCursor - 5
9175  if RUNstatus.get() == 0:
9176  UpdateXYScreen()
9177  except:
9178  donothing()
9179  try:
9180  if event.widget == Freqca:
9181  if ShowdBCur.get() > 0 and shift_key == 0:
9182  dBCursor = dBCursor - 1
9183  elif ShowdBCur.get() > 0 and shift_key == 1:
9184  dBCursor = dBCursor - 5
9185  if RUNstatus.get() == 0:
9187  except:
9188  donothing()
9189  try:
9190  if event.widget == Bodeca:
9191  if ShowBdBCur.get() > 0 and shift_key == 0:
9192  BdBCursor = BdBCursor - 1
9193  elif ShowBdBCur.get() > 0 and shift_key == 1:
9194  BdBCursor = BdBCursor - 5
9195  if RUNstatus.get() == 0:
9197  except:
9198  donothing()
9199 
9201  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
9202 
9203  shift_key = event.state & 1
9204  if event.widget == ca:
9205  if ShowVCur.get() > 0 and shift_key == 0:
9206  VCursor = VCursor + 1
9207  elif ShowVCur.get() > 0 and shift_key == 1:
9208  VCursor = VCursor + 5
9209  if RUNstatus.get() == 0:
9211  try:
9212  if event.widget == XYca:
9213  if ShowYCur.get() > 0 and shift_key == 0:
9214  YCursor = YCursor + 1
9215  elif ShowYCur.get() > 0 and shift_key == 1:
9216  YCursor = YCursor + 5
9217  if RUNstatus.get() == 0:
9218  UpdateXYScreen()
9219  except:
9220  donothing()
9221  try:
9222  if event.widget == Freqca:
9223  if ShowdBCur.get() > 0 and shift_key == 0:
9224  dBCursor = dBCursor + 1
9225  elif ShowdBCur.get() > 0 and shift_key == 1:
9226  dBCursor = dBCursor + 5
9227  if RUNstatus.get() == 0:
9229  except:
9230  donothing()
9231  try:
9232  if event.widget == Bodeca:
9233  if ShowBdBCur.get() > 0 and shift_key == 0:
9234  BdBCursor = BdBCursor + 1
9235  elif ShowBdBCur.get() > 0 and shift_key == 1:
9236  BdBCursor = BdBCursor + 5
9237  if RUNstatus.get() == 0:
9239  except:
9240  donothing()
9241 
9243  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9244 
9245  shift_key = event.state & 1
9246  if event.widget == ca:
9247  if ShowTCur.get() > 0 and shift_key == 0:
9248  TCursor = TCursor - 1
9249  elif ShowTCur.get() > 0 and shift_key == 1:
9250  TCursor = TCursor - 5
9251  if RUNstatus.get() == 0:
9253  try:
9254  if event.widget == XYca:
9255  if ShowXCur.get() > 0 and shift_key == 0:
9256  XCursor = XCursor - 1
9257  elif ShowXCur.get() > 0 and shift_key == 1:
9258  XCursor = XCursor - 5
9259  if RUNstatus.get() == 0:
9260  UpdateXYScreen()
9261  except:
9262  donothing()
9263  try:
9264  if event.widget == Freqca:
9265  if ShowFCur.get() > 0 and shift_key == 0:
9266  FCursor = FCursor - 1
9267  elif ShowFCur.get() > 0 and shift_key == 1:
9268  FCursor = FCursor - 5
9269  if RUNstatus.get() == 0:
9271  except:
9272  donothing()
9273  try:
9274  if event.widget == Bodeca:
9275  if ShowBPCur.get() > 0 and shift_key == 0:
9276  BPCursor = BPCursor - 1
9277  elif ShowBPCur.get() > 0 and shift_key == 1:
9278  BPCursor = BPCursor - 5
9279  if RUNstatus.get() == 0:
9281  except:
9282  donothing()
9283 
9285  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9286 
9287  shift_key = event.state & 1
9288  if event.widget == ca:
9289  if ShowTCur.get() > 0 and shift_key == 0:
9290  TCursor = TCursor + 1
9291  elif ShowTCur.get() > 0 and shift_key == 1:
9292  TCursor = TCursor + 5
9293  if RUNstatus.get() == 0:
9295  try:
9296  if event.widget == XYca:
9297  if ShowXCur.get() > 0 and shift_key == 0:
9298  XCursor = XCursor + 1
9299  elif ShowXCur.get() > 0 and shift_key == 1:
9300  XCursor = XCursor + 5
9301  if RUNstatus.get() == 0:
9302  UpdateXYScreen()
9303  except:
9304  donothing()
9305  try:
9306  if event.widget == Freqca:
9307  if ShowFCur.get() > 0 and shift_key == 0:
9308  FCursor = FCursor + 1
9309  elif ShowFCur.get() > 0 and shift_key == 1:
9310  FCursor = FCursor + 5
9311  if RUNstatus.get() == 0:
9313  except:
9314  donothing()
9315  try:
9316  if event.widget == Bodeca:
9317  if ShowBPCur.get() > 0 and shift_key == 0:
9318  BPCursor = BPCursor + 1
9319  elif ShowBPCur.get() > 0 and shift_key == 1:
9320  BPCursor = BPCursor + 5
9321  if RUNstatus.get() == 0:
9323  except:
9324  donothing()
9325 
9326 def onCanvasSpaceBar(event):
9327  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
9328 
9329  if event.widget == ca:
9330  if RUNstatus.get() == 0:
9331  BStart()
9332  elif RUNstatus.get() > 0:
9333  BStop()
9334  try:
9335  if event.widget == XYca:
9336  if RUNstatus.get() == 0:
9337  BStart()
9338  elif RUNstatus.get() > 0:
9339  BStop()
9340  except:
9341  donothing()
9342  try:
9343  if event.widget == IAca:
9344  if RUNstatus.get() == 0:
9345  BStart()
9346  elif RUNstatus.get() > 0:
9347  BStop()
9348  except:
9349  donothing()
9350  try:
9351  if event.widget == Freqca:
9352  if RUNstatus.get() == 0:
9353  BStartSA()
9354  elif RUNstatus.get() > 0:
9355  BStopSA()
9356  except:
9357  donothing()
9358  try:
9359  if event.widget == Bodeca:
9360  if RUNstatus.get() == 0:
9361  BStartBP()
9362  elif RUNstatus.get() > 0:
9363  BStopBP()
9364  except:
9365  donothing()
9366 #
9368  global X0L # Left top X value
9369  global Y0T # Left top Y value
9370  global GRW # Screenwidth
9371  global GRH # Screenheight
9372  global FontSize
9373  global ca, MarkerLoc, Mulx, Roll_Mode
9374  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9375  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
9376  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
9377  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
9378  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9379  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9380  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9381  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
9382  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
9383  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
9384 
9385  try:
9386  HoldOff = float(eval(HoldOffentry.get()))
9387  if HoldOff < 0:
9388  HoldOff = 0
9389  except:
9390  HoldOffentry.delete(0,END)
9391  HoldOffentry.insert(0, HoldOff)
9392  # get time scale
9393  try:
9394  TIMEdiv = float(eval(TMsb.get()))
9395  except:
9396  TIMEdiv = 0.5
9397  TMsb.delete(0,"end")
9398  TMsb.insert(0,TIMEdiv)
9399  # prevent divide by zero error
9400  if TIMEdiv < 0.0002:
9401  TIMEdiv = 0.01
9402  # add markers only if stopped
9403  if (RUNstatus.get() == 0):
9404  MarkerNum = MarkerNum + 1
9405  # get the vertical ranges
9406  try:
9407  CH1pdvRange = float(eval(CHAsb.get()))
9408  except:
9409  CHAsb.delete(0,END)
9410  CHAsb.insert(0, CH1pdvRange)
9411  try:
9412  CH2pdvRange = float(eval(CHBsb.get()))
9413  except:
9414  CHBsb.delete(0,END)
9415  CHBsb.insert(0, CH2pdvRange)
9416  try:
9417  CH1IpdvRange = float(eval(CHAIsb.get()))
9418  except:
9419  CHAIsb.delete(0,END)
9420  CHAIsb.insert(0, CH1IpdvRange)
9421  try:
9422  CH2IpdvRange = float(eval(CHBIsb.get()))
9423  except:
9424  CHBIsb.delete(0,END)
9425  CHBIsb.insert(0, CH2IpdvRange)
9426  # get the vertical offsets
9427  try:
9428  CHAOffset = float(eval(CHAVPosEntry.get()))
9429  except:
9430  CHAVPosEntry.delete(0,END)
9431  CHAVPosEntry.insert(0, CHAOffset)
9432  try:
9433  CHAIOffset = float(eval(CHAIPosEntry.get()))
9434  except:
9435  CHAIPosEntry.delete(0,END)
9436  CHAIPosEntry.insert(0, CHAIOffset)
9437  try:
9438  CHBOffset = float(eval(CHBVPosEntry.get()))
9439  except:
9440  CHBVPosEntry.delete(0,END)
9441  CHBVPosEntry.insert(0, CHBOffset)
9442  try:
9443  CHBIOffset = float(eval(CHBIPosEntry.get()))
9444  except:
9445  CHBIPosEntry.delete(0,END)
9446  CHBIPosEntry.insert(0, CHBIOffset)
9447  # prevent divide by zero error
9448  if CH1pdvRange < 0.001:
9449  CH1pdvRange = 0.001
9450  if CH2pdvRange < 0.001:
9451  CH2pdvRange = 0.001
9452  if CH1IpdvRange < 1.0:
9453  CH1IpdvRange = 1.0
9454  if CH2IpdvRange < 1.0:
9455  CH2IpdvRange = 1.0
9456 #
9457  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
9458  try:
9459  CHMApdvRange = float(eval(CHB_Asb.get()))
9460  except:
9461  CHB_Asb.delete(0,END)
9462  CHB_Asb.insert(0, CHMApdvRange)
9463  try:
9464  CHMBpdvRange = float(eval(CHB_Bsb.get()))
9465  except:
9466  CHB_Bsb.delete(0,END)
9467  CHB_Bsb.insert(0, CHMBpdvRange)
9468  try:
9469  CHMCpdvRange = float(eval(CHB_Csb.get()))
9470  except:
9471  CHB_Csb.delete(0,END)
9472  CHB_Csb.insert(0, CHMCpdvRange)
9473  try:
9474  CHMDpdvRange = float(eval(CHB_Dsb.get()))
9475  except:
9476  CHB_Dsb.delete(0,END)
9477  CHB_Dsb.insert(0, CHMDpdvRange)
9478  YconvMA = float(GRH/10.0) / CHMApdvRange
9479  YconvMB = float(GRH/10.0) / CHMBpdvRange
9480  YconvMC = float(GRH/10.0) / CHMCpdvRange
9481  YconvMD = float(GRH/10.0) / CHMDpdvRange
9482  try:
9483  CHBAOffset = float(eval(CHB_APosEntry.get()))
9484  except:
9485  CHB_APosEntry.delete(0,END)
9486  CHB_APosEntry.insert(0, CHBAOffset)
9487  try:
9488  CHBBOffset = float(eval(CHB_BPosEntry.get()))
9489  except:
9490  CHB_BPosEntry.delete(0,END)
9491  CHB_BPosEntry.insert(0, CHBBOffset)
9492  try:
9493  CHBCOffset = float(eval(CHB_CPosEntry.get()))
9494  except:
9495  CHB_CPosEntry.delete(0,END)
9496  CHB_CPosEntry.insert(0, CHBCOffset)
9497  try:
9498  CHBDOffset = float(eval(CHB_DPosEntry.get()))
9499  except:
9500  CHB_DPosEntry.delete(0,END)
9501  CHB_DPosEntry.insert(0, CHBDOffset)
9502  Yoffset1 = CHAOffset
9503  if MarkerScale.get() == 1:
9504  Yconv1 = float(GRH/10.0) / CH1pdvRange
9505  Yoffset1 = CHAOffset
9506  COLORmarker = COLORtrace1
9507  Units = " V"
9508  elif MarkerScale.get() == 2:
9509  Yconv1 = float(GRH/10.0) / CH2pdvRange
9510  Yoffset1 = CHBOffset
9511  COLORmarker = COLORtrace2
9512  Units = " V"
9513  elif MarkerScale.get() == 3:
9514  Yconv1 = float(GRH/10.0) / CH1IpdvRange
9515  Yoffset1 = CHAIOffset
9516  COLORmarker = COLORtrace3
9517  Units = " mA"
9518  elif MarkerScale.get() == 4:
9519  Yconv1 = float(GRH/10.0) / CH2IpdvRange
9520  Yoffset1 = CHBIOffset
9521  COLORmarker = COLORtrace4
9522  Units = " mA"
9523  # Aanalog Mux settings
9524  elif MarkerScale.get() == 5:
9525  Yconv1 = float(GRH/10.0) / CHMApdvRange
9526  Yoffset1 = CHBAOffset
9527  COLORmarker = COLORtrace2
9528  Units = " V"
9529  elif MarkerScale.get() == 6:
9530  Yconv1 = float(GRH/10.0) / CHMBpdvRange
9531  Yoffset1 = CHBBOffset
9532  COLORmarker = COLORtrace6
9533  Units = " V"
9534  elif MarkerScale.get() == 7:
9535  Yconv1 = float(GRH/10.0) / CHMCpdvRange
9536  Yoffset1 = CHBCOffset
9537  COLORmarker = COLORtrace7
9538  Units = " V"
9539  elif MarkerScale.get() == 8:
9540  Yconv1 = float(GRH/10.0) / CHMDpdvRange
9541  Yoffset1 = CHBDOffset
9542  COLORmarker = COLORtrace4
9543  Units = " V"
9544  else:
9545  Yconv1 = float(GRH/10.0) / CH1pdvRange
9546  Yoffset1 = CHAOffset
9547  COLORmarker = COLORtrace1
9548  Units = " V"
9549  #
9550  c1 = GRH / 2.0 + Y0T # fixed correction channel A
9551  xc1 = GRW / 2.0 + X0L
9552  c2 = GRH / 2.0 + Y0T # fixed correction channel B
9553  # draw X at marker point and number
9554  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9555  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9556  # DISsamples = (10.0 * TIMEdiv) # grid width in time
9557  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9558  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
9559  #
9560  Tpoint = Tpoint/Mulx
9561  if Tpoint >= 1000:
9562  axis_value = Tpoint / 1000.0
9563  TString = ' {0:.2f} '.format(axis_value) + " S "
9564  if Tpoint < 1000 and Tpoint >= 1:
9565  axis_value = Tpoint
9566  TString = ' {0:.2f} '.format(axis_value) + " mS "
9567  if Tpoint < 1:
9568  axis_value = Tpoint * 1000.0
9569  TString = ' {0:.2f} '.format(axis_value) + " uS "
9570  # TString = ' {0:.2f} '.format(Tpoint)
9571  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
9572  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9573  V1String = ' {0:.3f} '.format(-yvolts)
9574  else:
9575  V1String = ' {0:.1f} '.format(-yvolts)
9576  V_label = str(MarkerNum) + " " + TString + V1String
9577  V_label = V_label + Units
9578  if MarkerNum > 1:
9579  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9580  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
9581  else:
9582  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
9583  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
9584  DT = (Tpoint-PrevT)
9585  if Tpoint >= 1000:
9586  axis_value = DT / 1000.0
9587  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
9588  if Tpoint < 1000 and Tpoint >= 1:
9589  axis_value = DT
9590  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
9591  if Tpoint < 1:
9592  axis_value = DT * 1000.0
9593  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
9594  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
9595  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
9596  V_label = V_label + " Delta " + DeltaT + DeltaV
9597  V_label = V_label + Units
9598  V_label = V_label + ", Freq " + DFreq + " KHz"
9599  else:
9600  V_label = V_label + " Delta " + DeltaV + Units
9601  # place in upper left unless specified otherwise
9602  x = X0L + 5
9603  y = Y0T + 3 + (MarkerNum*10)
9604  Justify = 'w'
9605  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
9606  x = X0L + GRW - 5
9607  y = Y0T + 3 + (MarkerNum*10)
9608  Justify = 'e'
9609  if MarkerLoc == 'LL' or MarkerLoc == 'll':
9610  x = X0L + 5
9611  y = Y0T + GRH + 3 - (MarkerNum*10)
9612  Justify = 'w'
9613  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
9614  x = X0L + GRW - 5
9615  y = Y0T + GRH + 3 - (MarkerNum*10)
9616  Justify = 'e'
9617  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
9618  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
9619  PrevV = yvolts
9620  PrevT = Tpoint
9621  else:
9622  if MeasGateStatus.get() == 1:
9623  #DISsamples = (10.0 * TIMEdiv) # grid width in time
9624  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9625  if MeasGateNum == 0:
9626  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
9627  MeasGateNum = 1
9628  else:
9629  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
9630  MeasGateNum = 0
9631  LeftGate = X0L + MeasGateLeft / Tstep
9632  RightGate = X0L + MeasGateRight / Tstep
9633  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
9634  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
9635 
9636 #
9637 def onCanvasOne(event):
9638  global ShowC1_V
9639 
9640  if ShowC1_V.get() == 0:
9641  ShowC1_V.set(1)
9642  else:
9643  ShowC1_V.set(0)
9644 #
9645 def onCanvasTwo(event):
9646  global ShowC2_V
9647 
9648  if ShowC2_V.get() == 0:
9649  ShowC2_V.set(1)
9650  else:
9651  ShowC2_V.set(0)
9652 #
9653 def onCanvasThree(event):
9654  global ShowC1_I
9655 
9656  if ShowC1_I.get() == 0:
9657  ShowC1_I.set(1)
9658  else:
9659  ShowC1_I.set(0)
9660 #
9661 def onCanvasFour(event):
9662  global ShowC2_I
9663 
9664  if ShowC2_I.get() == 0:
9665  ShowC2_I.set(1)
9666  else:
9667  ShowC2_I.set(0)
9668 #
9669 def onCanvasFive(event):
9670  global MathTrace
9671 
9672  MathTrace.set(1)
9673 #
9674 def onCanvasSix(event):
9675  global MathTrace
9676 
9677  MathTrace.set(2)
9678 #
9679 def onCanvasSeven(event):
9680  global MathTrace
9681 
9682  MathTrace.set(3)
9683 #
9684 def onCanvasEight(event):
9685  global MathTrace
9686 
9687  MathTrace.set(10)
9688 #
9689 def onCanvasNine(event):
9690  global MathTrace
9691 
9692  MathTrace.set(12)
9693 #
9694 def onCanvasZero(event):
9695  global MathTrace
9696 
9697  MathTrace.set(0)
9698 #
9699 def onCanvasTrising(event):
9700  global TgEdge
9701 
9702  TgEdge.set(0)
9703 #
9704 def onCanvasTfalling(event):
9705  global TgEdge
9706 
9707  TgEdge.set(1)
9708 #
9709 def onCanvasSnap(event):
9710 
9711  BSnapShot()
9712 #
9713 def onCanvasAverage(event):
9714  global TRACEmodeTime
9715 
9716  if TRACEmodeTime.get() == 0:
9717  TRACEmodeTime.set(1)
9718  else:
9719  TRACEmodeTime.set(0)
9720 #
9721 def onCanvasShowTcur(event):
9722  global ShowTCur
9723 
9724  if ShowTCur.get() == 0:
9725  ShowTCur.set(1)
9726  else:
9727  ShowTCur.set(0)
9728 #
9729 def onCanvasShowVcur(event):
9730  global ShowVCur
9731 
9732  if ShowVCur.get() == 0:
9733  ShowVCur.set(1)
9734  else:
9735  ShowVCur.set(0)
9736 #
9738  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
9739 
9740  XCursor = event.x
9741  YCursor = event.y
9742  if RUNstatus.get() == 0:
9743  UpdateXYScreen()
9744  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
9745 #
9747  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
9748  if event.widget == XYca:
9749  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
9750  ShiftKeyDwn = event.state & 1
9751  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
9752  # respond to Linux or Windows wheel event
9753  if event.num == 5 or event.delta == -120:
9754  XCursor -= 1
9755  if event.num == 4 or event.delta == 120:
9756  XCursor += 1
9757  # XCursor = XCursor + event.delta/100
9758  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
9759  # respond to Linux or Windows wheel event
9760  if event.num == 5 or event.delta == -120:
9761  YCursor += 1
9762  if event.num == 4 or event.delta == 120:
9763  YCursor -= 1
9764  #YCursor = YCursor - event.delta/100
9765  if RUNstatus.get() == 0:
9766  UpdateXYScreen()
9767 #
9769  global X0LXY # Left top X value
9770  global Y0TXY # Left top Y value
9771  global GRWXY # Screenwidth
9772  global GRHXY # Screenheight
9773  global FontSize
9774  global XYca
9775  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9776  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
9777  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
9778  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
9779  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9780  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9781  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9782  # add markers only if stopped
9783  #
9784  if (RUNstatus.get() == 0):
9785  MarkerNum = MarkerNum + 1
9786  try:
9787  CH1pdvRange = float(eval(CHAsbxy.get()))
9788  except:
9789  CHAsbxy.delete(0,END)
9790  CHAsbxy.insert(0, CH1pdvRange)
9791  try:
9792  CH2pdvRange = float(eval(CHBsbxy.get()))
9793  except:
9794  CHBsb.delete(0,END)
9795  CHBsb.insert(0, CH2pdvRange)
9796  try:
9797  CH1IpdvRange = float(eval(CHAIsbxy.get()))
9798  except:
9799  CHAIsbxy.delete(0,END)
9800  CHAIsbxy.insert(0, CH1IpdvRange)
9801  try:
9802  CH2IpdvRange = float(eval(CHBIsbxy.get()))
9803  except:
9804  CHBIsbxy.delete(0,END)
9805  CHBIsbxy.insert(0, CH2IpdvRange)
9806  # get the vertical offsets
9807  try:
9808  CHAOffset = float(eval(CHAVPosEntryxy.get()))
9809  except:
9810  CHAVPosEntryxy.delete(0,END)
9811  CHAVPosEntryxy.insert(0, CHAOffset)
9812  try:
9813  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
9814  except:
9815  CHAIPosEntryxy.delete(0,END)
9816  CHAIPosEntryxy.insert(0, CHAIOffset)
9817  try:
9818  CHBOffset = float(eval(CHBVPosEntryxy.get()))
9819  except:
9820  CHBVPosEntryxy.delete(0,END)
9821  CHBVPosEntryxy.insert(0, CHBOffset)
9822  try:
9823  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
9824  except:
9825  CHBIPosEntryxy.delete(0,END)
9826  CHBIPosEntryxy.insert(0, CHBIOffset)
9827  # prevent divide by zero error
9828  if CH1pdvRange < 0.001:
9829  CH1pdvRange = 0.001
9830  if CH2pdvRange < 0.001:
9831  CH2pdvRange = 0.001
9832  if CH1IpdvRange < 1.0:
9833  CH1IpdvRange = 1.0
9834  if CH2IpdvRange < 1.0:
9835  CH2IpdvRange = 1.0
9836  try:
9837  HoldOff = float(eval(HoldOffentry.get()))
9838  if HoldOff < 0:
9839  HoldOff = 0
9840  except:
9841  HoldOffentry.delete(0,END)
9842  HoldOffentry.insert(0, HoldOff)
9843  #
9844  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
9845  Xconv1 = float(GRWXY/10) / CH1pdvRange
9846  Yconv2 = float(GRHXY/10) / CH2pdvRange
9847  Xconv2 = float(GRWXY/10) / CH2pdvRange
9848  YIconv1 = float(GRHXY/10) / CH1IpdvRange
9849  YIconv2 = float(GRHXY/10) / CH2IpdvRange
9850  COLORmarker = COLORtext
9851  Yoffset1 = CHAOffset
9852  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
9853  xc1 = GRWXY / 2 + X0LXY
9854  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
9855  # draw X at marker point and number
9856  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9857  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9858  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
9859  V_label = str(MarkerNum) + " "
9860  x = X0LXY + 5
9861  y = Y0TXY + 3 + (MarkerNum*10)
9862  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset # preset the variable
9863  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
9864  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
9865  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9866  VyString = ' {0:.3f} '.format(-yvolts)
9867  VxString = ' {0:.3f} '.format(-xvolts)
9868  V_label = V_label + VxString + " V, " + VyString + " V"
9869  if MarkerNum > 1:
9870  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9871  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9872  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9873  PrevY = yvolts
9874  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
9875  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
9876  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9877  VyString = ' {0:.3f} '.format(-yvolts)
9878  VxString = ' {0:.3f} '.format(-xvolts)
9879  V_label = V_label + VxString + " V, " + VyString + " V"
9880  if MarkerNum > 1:
9881  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9882  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9883  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9884  PrevY = yvolts
9885  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9886  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9887  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9888  VxString = ' {0:.3f} '.format(-xvolts)
9889  VyString = ' {0:.1f} '.format(-ymA)
9890  V_label = V_label + VxString + " V, " + VyString + " mA"
9891  if MarkerNum > 1:
9892  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9893  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9894  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9895  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9896  V_label = V_label + ", dV/dI " + DeltaR
9897  PrevY = ymA
9898  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9899  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9900  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9901  VxString = ' {0:.3f} '.format(-xvolts)
9902  VyString = ' {0:.1f} '.format(-ymA)
9903  V_label = V_label + VxString + " V, " + VyString + " mA"
9904  if MarkerNum > 1:
9905  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9906  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9907  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9908  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9909  V_label = V_label + ", dV/dI " + DeltaR
9910  PrevY = ymA
9911  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9912  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9913  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9914  VxString = ' {0:.3f} '.format(-xvolts)
9915  VyString = ' {0:.1f} '.format(-ymA)
9916  V_label = V_label + VxString + " V, " + VyString + " mA"
9917  if MarkerNum > 1:
9918  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9919  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9920  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9921  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9922  V_label = V_label + ", dV/dI " + DeltaR
9923  PrevY = ymA
9924  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9925  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9926  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9927  VxString = ' {0:.3f} '.format(-xvolts)
9928  VyString = ' {0:.1f} '.format(-ymA)
9929  V_label = V_label + VxString + " V, " + VyString + " mA"
9930  if MarkerNum > 1:
9931  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9932  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9933  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9934  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9935  V_label = V_label + ", dV/dI " + DeltaR
9936  PrevY = ymA
9937  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
9938  PrevX = xvolts
9939 #
9940 # Some DSP functions
9941 #
9942 # Generate Time-series From Half-spectrum code block
9943 # takes: a desired noise spectral density array (freq)
9944 # the sample rate of the time series (fs),
9945 # returns a time series of voltage samples that can be sent to the AWG
9946 #
9947 # DC in first element.
9948 # Output length is 2x input length
9949 def time_points_from_freq(freq, fs=1, density=False):
9950  N=len(freq)
9951  rnd_ph_pos = (numpy.ones(N-1, dtype=numpy.complex)*
9952  numpy.exp(1j*numpy.random.uniform
9953  (0.0,2.0*numpy.pi, N-1)))
9954  rnd_ph_neg = numpy.flip(numpy.conjugate(rnd_ph_pos))
9955  rnd_ph_full = numpy.concatenate(([1],rnd_ph_pos,[1], rnd_ph_neg))
9956  r_s_full = numpy.concatenate((freq, numpy.roll(numpy.flip(freq), 1)))
9957  r_spectrum_rnd_ph = r_s_full * rnd_ph_full
9958  r_time_full = numpy.fft.ifft(r_spectrum_rnd_ph)
9959 # print("RMS imaginary component: ",
9960 # np.std(np.imag(r_time_full)),
9961 # " Should be close to nothing")
9962  if (density == True):
9963  #Note that this N is "predivided" by 2
9964  r_time_full *= N*numpy.sqrt(fs/(N))
9965  return(numpy.real(r_time_full))
9966 #
9967 def TimeSeriesNoise(n, Fsample, mag, b=4):
9968  # Build Noise Time-series
9969  # n = number of Freq Bins
9970  # b = number of noise bands
9971  # Fsample is Sample Rate
9972  # generates four "bands" of mag V/rootHz noise
9973  mag = mag * 0.707106 # scale by 1/sqrt 2 for RMS
9974  width = int(n/(4 * b))
9975  i = 1
9976  aband = numpy.ones(width)
9977  zband = numpy.zeros(width)
9978  bands = numpy.concatenate((aband, zband))
9979  while i < b:
9980  bands = numpy.concatenate((bands, aband, zband))
9981  i = i + 1
9982  bands = bands*mag
9983  bands[0] = 0.0 # Set DC bin content to zero
9984  return time_points_from_freq(bands, fs=Fsample, density=True)
9985 #
9986 # Generate Time samples for single frequency Bin
9987 # Uses IFFT
9988 #
9989 def TimeSeriesSingleTone(n, BinNum, Fsample, mag):
9990  # Build Single tone Time-series
9991  # n = number of Freq Bins
9992  # BinNum = FFT Bin number
9993  # Fsample is Sample Rate
9994  # mag is tone amplitude
9995  bands = numpy.zeros(n)
9996  bands[BinNum] = 1
9997  bands = bands * (mag/2.0)
9998  return time_points_from_freq(bands, fs=Fsample, density=True)
9999 #
10000 def PinkNoise(N, mag):
10001  # Pink noise.
10002  # Pink noise has equal power in bands that are proportionally wide.
10003  # Power spectral density decreases with 3 dB per octave.
10004  # N Length of sample array, mag magnitude scaling factor
10005 
10006  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10007  X = numpy.fft.rfft(x) / N
10008  S = numpy.sqrt(numpy.arange(X.size)+1.0) # +1 to avoid divide by zero
10009  y = numpy.fft.irfft(X/S).real[:N] # extremely tiny value 1e-9 without normalization
10010  z = numpy.ndarray = mag
10011  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10012 
10013  return y
10014 #
10015 def BlueNoise(N, mag):
10016  # Blue noise.
10017  # Power increases with 6 dB per octave.
10018  # Power spectral density increases with 3 dB per octave.
10019  # N Length of sample array, mag magnitude scaling factor
10020 
10021  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10022  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10023  X = numpy.fft.rfft(x) / N
10024  S = numpy.sqrt(numpy.arange(X.size)) # Filter
10025  y = numpy.fft.irfft(X*S).real[:N]
10026  z = numpy.ndarray = mag
10027  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10028 
10029  return y
10030 #
10031 def BrownNoise(N, mag):
10032  # Brown noise.
10033  # Power decreases with -3 dB per octave.
10034  # Power spectral density decreases with 6 dB per octave.
10035  # N Length of sample array, mag magnitude scaling factor
10036 
10037  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10038  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10039  X = numpy.fft.rfft(x) / N
10040  S = numpy.arange(X.size)+1 # Filter
10041  y = numpy.fft.irfft(X/S).real[:N]
10042  z = numpy.ndarray = mag
10043  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10044 
10045  return y
10046 #
10047 def VioletNoise(N, mag):
10048  # Violet noise.
10049  # Power increases with +9 dB per octave.
10050  # Power density increases with +6 dB per octave.
10051  # N Length of sample array, mag magnitude scaling factor
10052 
10053  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10054  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10055  X = numpy.fft.rfft(x) / N
10056  S = numpy.arange(X.size) # Filter
10057  y = numpy.fft.irfft(X*S).real[0:N]
10058  z = numpy.ndarray = mag
10059  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10060 
10061  return y
10062 #
10063 def SchroederPhase(Length, NrTones, Ampl):
10064  # Generate a Schroeder Phase (Chirp) of Length samples and having NrTones
10065  OutArray = []
10066  OutArray = Ampl*numpy.cos(numpy.linspace(0, 2*numpy.pi, Length)) # the fundamental
10067  k = 2
10068  while k <= NrTones:
10069  # Add all harmonics up to NrTones
10070  Harmonic = Ampl*numpy.cos(numpy.linspace(0, k*2*numpy.pi, Length)+(numpy.pi*k*k/NrTones))
10071  OutArray = OutArray + Harmonic
10072  k = k + 1
10073  OutArray = OutArray + 2.5 # Center wavefrom on 2.5 V
10074  return(OutArray)
10075 #
10076 def Wrap(InArray, WrFactor):
10077  # Build new array by skipping WrFactor samples and wrapping back around
10078  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
10079  # effectively multiplies the frequency content by WrFactor
10080  OutArray = []
10081  OutArray = numpy.array(OutArray)
10082  InArray = numpy.array(InArray)
10083  EndIndex = len(InArray)
10084  StartIndex = 0
10085  while StartIndex < WrFactor:
10086  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
10087  StartIndex = StartIndex + 1
10088  return OutArray
10089 #
10090 def UnWrap(InArray, WrFactor):
10091  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
10092  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
10093  # effectively divided the frequency content by WrFactor
10094  OutArray = []
10095  InArray = numpy.array(InArray)
10096  EndIndex = int(len(InArray)/WrFactor)
10097  StartIndex = 0
10098  while StartIndex < EndIndex:
10099  LoopIndex = 0
10100  while LoopIndex < WrFactor:
10101  OutArray.append(InArray[StartIndex+LoopIndex])
10102  LoopIndex = LoopIndex + 1
10103  StartIndex = StartIndex + 1
10104  OutArray = numpy.array(OutArray)
10105  return OutArray
10106 #
10107 def Write_WAV(data, repeat, filename):
10108  global SAMPLErate
10109  # write data array to mono .wav file 100KSPS
10110  # copy buffer repeat times in output file
10111  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
10112  wavfile = wave.open(filename, "w")
10113  nchannels = 1
10114  sampwidth = 2
10115  framerate = SAMPLErate
10116  amplitude = 32766
10117  nframes = len(data)
10118  comptype = "NONE"
10119  compname = "not compressed"
10120  wavfile.setparams((nchannels,
10121  sampwidth,
10122  framerate,
10123  nframes,
10124  comptype,
10125  compname))
10126  # Normalize data
10127  ArrN = numpy.array(data)
10128  ArrN /= numpy.max(numpy.abs(data))
10129  frames = []
10130  for s in ArrN:
10131  mul = int(s * amplitude)
10132  # print "s: %f mul: %d" % (s, mul)
10133  frames.append(struct.pack('h', mul))
10134  print( len(frames))
10135  frames = ''.join(frames)
10136  print( len(frames))
10137  for x in xrange(0, repeat):
10138  print( x )
10139  wavfile.writeframes(frames)
10140  wavfile.close()
10141 
10142 # =========== Awg functions ==================
10143 def BAWGAAmpl(temp):
10144  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10145  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10146 
10147  try:
10148  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
10149  except:
10150  AWGAAmplEntry.delete(0,"end")
10151  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10152  #
10153  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10154  if AWGAMode.get() == 0: # Source Voltage measure current mode
10155  if AWGAAmplvalue > 5.00:
10156  AWGAAmplvalue = 5.00
10157  AWGAAmplEntry.delete(0,"end")
10158  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10159  if AWGAAmplvalue < 0.00:
10160  AWGAAmplvalue = 0.00
10161  AWGAAmplEntry.delete(0,"end")
10162  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10163  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10164  if AWGAMode.get() == 0: # Source Voltage measure current mode
10165  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
10166  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
10167  AWGAAmplEntry.delete(0,"end")
10168  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10169  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
10170  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
10171  AWGAAmplEntry.delete(0,"end")
10172  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10173  if AWGAMode.get() == 1: # Source current measure voltage mode
10174  if AWGAAmplvalue > 200.00:
10175  AWGAAmplvalue = 200.00
10176  AWGAAmplEntry.delete(0,"end")
10177  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10178  if AWGAAmplvalue < -200.00:
10179  AWGAAmplvalue = -200.00
10180  AWGAAmplEntry.delete(0,"end")
10181  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10182 #
10183 def BAWGAOffset(temp):
10184  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10185  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10186 
10187  try:
10188  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10189  except:
10190  AWGAOffsetEntry.delete(0,"end")
10191  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10192  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10193  if AWGAMode.get() == 0: # Source Voltage measure current mode
10194  if AWGAOffsetvalue > 5.00:
10195  AWGAOffsetvalue = 5.00
10196  AWGAOffsetEntry.delete(0,"end")
10197  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10198  if AWGAOffsetvalue < 0.00:
10199  AWGAOffsetvalue = 0.00
10200  AWGAOffsetEntry.delete(0,"end")
10201  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10202  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10203  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
10204  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
10205  AWGAOffsetEntry.delete(0,"end")
10206  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10207  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
10208  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
10209  AWGAOffsetEntry.delete(0,"end")
10210  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10211  if AWGAMode.get() == 1: # Source current measure voltage mode
10212  if AWGAOffsetvalue > 200.00:
10213  AWGAOffsetvalue = 200.00
10214  AWGAOffsetEntry.delete(0,"end")
10215  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10216  if AWGAOffsetvalue < -200.00:
10217  AWGAOffsetvalue = -200.00
10218  AWGAOffsetEntry.delete(0,"end")
10219  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10220 #
10221 def BAWGAFreq(temp):
10222  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
10223  global BodeScreenStatus, BodeDisp, AWGRecLength
10224 
10225  try:
10226  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
10227  except:
10228  AWGAFreqEntry.delete(0,"end")
10229  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10230  if AWG_2X.get() == 1:
10231  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10232  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
10233  AWGAFreqvalue = 90000
10234  AWGAFreqEntry.delete(0,"end")
10235  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10236  else:
10237  if AWGAFreqvalue > 50000: # max freq is 50KHz
10238  AWGAFreqvalue = 50000
10239  AWGAFreqEntry.delete(0,"end")
10240  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10241  else:
10242  if AWGAFreqvalue > 25000: # max freq is 25KHz
10243  AWGAFreqvalue = 25000
10244  AWGAFreqEntry.delete(0,"end")
10245  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10246  if AWGAFreqvalue < 4.0:
10247  AWGRecLength = 32768*2
10248  else:
10249  AWGRecLength = 32768
10250  if AWGAFreqvalue < 0: # Set negative frequency entry to 10
10251  AWGAFreqvalue = 10
10252  AWGAFreqEntry.delete(0,"end")
10253  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10254  #UpdateAWGA()
10255 
10257  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10258 
10259  if AWGAPhaseDelay.get() == 1:
10260  AWGAPhaseDelay.set(0)
10261  awgaph.configure(text="Phase")
10262  phasealab.configure(text="Deg")
10263  elif AWGAPhaseDelay.get() == 0:
10264  AWGAPhaseDelay.set(1)
10265  awgaph.configure(text="Delay")
10266  phasealab.configure(text="mSec")
10267 
10269  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10270 
10271  if AWGAPhaseDelay.get() == 0:
10272  phasealab.configure(text="Deg")
10273  awgaph.configure(text="Phase")
10274  elif AWGAPhaseDelay.get() == 1:
10275  phasealab.configure(text="mSec")
10276  awgaph.configure(text="Delay")
10277 
10278 def BAWGAPhase(temp):
10279  global AWGAPhaseEntry, AWGAPhasevalue
10280 
10281  try:
10282  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
10283  except:
10284  AWGAPhaseEntry.delete(0,"end")
10285  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10286 
10287  if AWGAPhasevalue > 360: # max phase is 360 degrees
10288  AWGAPhasevalue = 360
10289  AWGAPhaseEntry.delete(0,"end")
10290  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10291  if AWGAPhasevalue < 0: # min phase is 0 degrees
10292  AWGAPhasevalue = 0
10293  AWGAPhaseEntry.delete(0,"end")
10294  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10295 
10296 def BAWGADutyCycle(temp):
10297  global AWGADutyCycleEntry, AWGADutyCyclevalue
10298 
10299  try:
10300  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
10301  except:
10302  AWGADutyCycleEntry.delete(0,"end")
10303  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10304 
10305  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
10306  AWGADutyCyclevalue = 1
10307  AWGADutyCycleEntry.delete(0,"end")
10308  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
10309  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
10310  AWGADutyCyclevalue = 0
10311  AWGADutyCycleEntry.delete(0,"end")
10312  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10313  #UpdateAWGA()
10314 
10316  global AWGAShape, AWGAWave, phasealab, duty1lab
10317 
10318  if AWGAShape.get() == 0:
10319  AWGAWave = 'dc'
10320  duty1lab.config(text="%")
10321  BAWGAPhaseDelay()
10322  if AWGAShape.get() == 1:
10323  AWGAWave = 'sine'
10324  duty1lab.config(text="%")
10325  BAWGAPhaseDelay()
10326  if AWGAShape.get() == 2:
10327  AWGAWave = 'triangle'
10328  duty1lab.config(text="%")
10329  BAWGAPhaseDelay()
10330  if AWGAShape.get() == 3:
10331  AWGAWave = 'sawtooth'
10332  duty1lab.config(text="%")
10333  BAWGAPhaseDelay()
10334  if AWGAShape.get() == 4:
10335  AWGAWave = 'square'
10336  duty1lab.config(text="%")
10337  BAWGAPhaseDelay()
10338  if AWGAShape.get() == 5:
10339  AWGAWave = 'stairstep'
10340  duty1lab.config(text="%")
10341  BAWGAPhaseDelay()
10342  if AWGAShape.get() > 5:
10343  AWGAWave = 'arbitrary'
10344  # UpdateAWGA()
10345 
10347  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10348 
10349  # Read values from CVS file
10350  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10351  AWGAcsvFile = filename
10352  AWGALoadCSV()
10353 #
10355  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile, AWGAOffsetvalue
10356 
10357  BAWGAOffset(0)
10358  try:
10359  CSVFile = open(AWGAcsvFile)
10360  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
10361  CSVFile.seek(0)
10362  #csv_f = csv.reader(CSVFile, dialect)
10363  csv_f = csv.reader(CSVFile, csv.excel)
10364  except:
10365  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10366  # print csv_f.dialect
10367  AWGAwaveform = []
10368  ColumnNum = 0
10369  ColumnSel = 0
10370  RowNum = 0
10371  for row in csv_f:
10372  # print 'found row = ', row
10373  if len(row) > 1 and ColumnSel == 0:
10374  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10375  ColumnNum = int(RequestColumn) - 1
10376  ColumnLen = str(len(row))
10377  ColumnSel = 1
10378  try:
10379  colnum = 0
10380  for col in row:
10381  if colnum == ColumnNum:
10382  AWGAwaveform.append(float(col))
10383  colnum += 1
10384  except:
10385  print( 'skipping non-numeric row', RowNum)
10386  RowNum += 1
10387  AWGAwaveform = numpy.array(AWGAwaveform)
10388  AWGAwaveform = AWGAwaveform + AWGAOffsetvalue # add DC offset from Max entry
10390  CSVFile.close()
10391  UpdateAwgCont()
10392 
10393 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
10395  global AWG_2X, AWGA2X, AWGAwaveform
10396  global AWGFiltA, AWGFiltACoef
10397 
10398  # check if AWG digital filter box checked
10399  if AWGFiltA.get() == 1:
10400  BufLen = len(AWGAwaveform)
10401  CoefLen = len(AWGFiltACoef)/2
10402  AWGAwaveform = numpy.pad(AWGAwaveform, (CoefLen,CoefLen), 'wrap')
10403  AWGAwaveform = numpy.convolve(AWGAwaveform, AWGFiltACoef)
10404  AWGAwaveform = numpy.roll(AWGAwaveform, -CoefLen)
10405  AWGAwaveform = AWGAwaveform[CoefLen:BufLen+CoefLen]
10406 
10407  if AWG_2X.get() == 1:
10408  Tempwaveform = []
10409  AWGA2X = []
10410  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
10411  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
10412  AWGAwaveform = Tempwaveform
10413 #
10415  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10416 
10417  if AWGABurstFlag.get() == 1:
10418  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
10419  if (AWGACyclesString == None): # If Cancel pressed, then None
10420  return
10421  AWGACycles = int(AWGACyclesString)
10422  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
10423  if (AWGADelayString == None): # If Cancel pressed, then None
10424  return
10425  AWGABurstDelay = float(AWGADelayString)
10426  ReMakeAWGwaves()
10427 #
10429  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10430  global AWG_2X, AWGA2X, AWGAwavFile
10431 
10432 # Read values from WAV file
10433  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10434  AWGAwavFile = filename
10435  AWGALoadWAV()
10436 #
10438  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10439  global AWG_2X, AWGA2X, AWGAwavFile
10440 
10441  try:
10442  spf = wave.open(AWGAwavFile,'r')
10443  except:
10444  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10445  AWGAwaveform = []
10446  AWGBwaveform = []
10447  Length = spf.getnframes()
10448  if Length > 90000:
10449  Length = 90000
10450  # If Stereo put first channel in AWGA and second channel in AWGB
10451  if spf.getnchannels() == 2:
10452  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
10453  signal = spf.readframes(Length)
10454  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
10455  n = 0
10456  while n < Length*2:
10457  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10458  n = n + 1
10459  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10460  n = n + 1
10461  AWGAwaveform = numpy.array(AWGAwaveform)
10462  AWGBwaveform = numpy.array(AWGBwaveform)
10463  AWGBShape.set(AWGAShape.get())
10464  else:
10465  #Extract Raw Audio from Wav File
10466  signal = spf.readframes(Length)
10467  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10468  # offset and scale for 0 5 V range
10469  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10470  AWGAwaveform = numpy.array(AWGAwaveform)
10472  spf.close()
10473  UpdateAwgCont()
10474 
10476  global AWGAwaveform, AWGALength, awgwindow
10477 
10478  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10479  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
10480 
10482  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10483  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10484  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10485  global DFiltACoef, DFiltBCoef, AWGAShapeLabel, AWGALength
10486  global AWG_2X, AWGA2X
10487 
10488  TempString = AWGAMathString
10489  AWGAShapeLabel.config(text = "Math" ) # change displayed value
10490  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
10491  if (AWGAMathString == None): # If Cancel pressed, then None
10492  AWGAMathString = TempString
10493  return
10494  try:
10495  AWGAwaveform = eval(AWGAMathString)
10496  except:
10497  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
10498  AWGAwaveform = numpy.array(AWGAwaveform)
10500  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10501  UpdateAwgCont()
10502 #
10504  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10505  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10506  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10507  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
10508  global AWG_2X, AWGA2X
10509 
10510  AWGAwaveform = eval(AWGAMathString)
10511  AWGAwaveform = numpy.array(AWGAwaveform)
10513  UpdateAwgCont()
10514 #
10516  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10517  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10518  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode, AWGRecLength
10519  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10520 
10521  BAWGAAmpl(0)
10522  BAWGAOffset(0)
10523  BAWGAFreq(0)
10524  BAWGAPhase(0)
10525  BAWGADutyCycle(0)
10526  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
10527  if AWGAFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
10528  AWGAShape.set(1)
10529  BAWGAShape()
10530  UpdateAwgCont()
10531  return
10532 
10533  if AWGAFreqvalue > 0.0:
10534  if AWG_2X.get() == 1:
10535  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10536  else:
10537  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10538  else:
10539  AWGAperiodvalue = 10.0
10540 
10541  if AWGAPhaseDelay.get() == 0:
10542  if AWGAPhasevalue > 0:
10543  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10544  else:
10545  AWGAdelayvalue = 0.0
10546  elif AWGAPhaseDelay.get() == 1:
10547  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10548  Cycles = int(AWGRecLength/AWGAperiodvalue)
10549  if Cycles < 1:
10550  Cycles = 1
10551  RecLength = int(Cycles * AWGAperiodvalue)
10552  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10553  RecLength = RecLength + 1
10554  AWGAwaveform = []
10555  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10556 
10557  if AWG_Amp_Mode.get() == 0:
10558  if AWGAMode.get() == 1: # convert to mA
10559  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10560  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10561  else:
10562  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10563  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10564  else:
10565  if AWGAMode.get() == 1: # convert to mA
10566  amplitude = AWGAAmplvalue/1000.0
10567  offset = AWGAOffsetvalue/1000.0
10568  else:
10569  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10570  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10571  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10572  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10573 #
10575  BAWGAPhaseDelay()
10576  duty1lab.config(text="%")
10577  UpdateAwgCont()
10578 #
10580  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10581  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10582  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10583  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10584 
10585  BAWGAAmpl(0)
10586  BAWGAOffset(0)
10587  BAWGAFreq(0)
10588 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10589  duty1lab.config(text = "M Index")
10590  phasealab.config(text = "M Freq")
10591 
10592  if AWGAFreqvalue > 0.0:
10593  if AWG_2X.get() == 1:
10594  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10595  else:
10596  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10597  else:
10598  AWGAperiodvalue = 10.0
10599 
10600  try:
10601  ModFreq = float(eval(AWGAPhaseEntry.get()))
10602  except:
10603  ModFreq = 10
10604  AWGAPhaseEntry.delete(0,"end")
10605  AWGAPhaseEntry.insert(0, ModFreq)
10606 
10607  if ModFreq < 10:
10608  ModFreq = 10
10609  AWGAPhaseEntry.delete(0,"end")
10610  AWGAPhaseEntry.insert(0, ModFreq)
10611 
10612  if AWG_2X.get() == 1:
10613  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10614  else:
10615  MODperiodvalue = BaseSampleRate/ModFreq
10616 
10617  try:
10618  ModIndex = float(eval(AWGADutyCycleEntry.get()))
10619  except:
10620  ModIndex = 1.0
10621  AWGADutyCycleEntry.delete(0,"end")
10622  AWGADutyCycleEntry.insert(0, ModIndex)
10623 
10624  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10625  if ModCycles < 1:
10626  ModCycles = 1
10627  RecLength = int(ModCycles * MODperiodvalue)
10628  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10629  RecLength = RecLength + 1
10630  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10631  AWGAwaveform = []
10632  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
10633  if AWG_Amp_Mode.get() == 0:
10634  if AWGAMode.get() == 1: # convert to mA
10635  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10636  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10637  else:
10638  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10639  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10640  else:
10641  if AWGAMode.get() == 1: # convert to mA
10642  amplitude = AWGAAmplvalue/1000.0
10643  offset = AWGAOffsetvalue/1000.0
10644  else:
10645  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10646  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10647  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10648  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10649 #
10650  SplitAWGAwaveform() # if needed
10651  UpdateAwgCont()
10652 #
10654  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10655  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10656  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10657  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10658 
10659  BAWGAAmpl(0)
10660  BAWGAOffset(0)
10661  BAWGAFreq(0)
10662 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10663  duty1lab.config(text = "M Index")
10664  phasealab.config(text = "M Freq")
10665 
10666  if AWGAFreqvalue > 0.0:
10667  if AWG_2X.get() == 1:
10668  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10669  else:
10670  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10671  else:
10672  AWGAperiodvalue = 10.0
10673 
10674  try:
10675  ModFreq = float(eval(AWGAPhaseEntry.get()))
10676  except:
10677  ModFreq = 10
10678  AWGAPhaseEntry.delete(0,"end")
10679  AWGAPhaseEntry.insert(0, ModFreq)
10680 
10681  if ModFreq < 10:
10682  ModFreq = 10
10683  AWGAPhaseEntry.delete(0,"end")
10684  AWGAPhaseEntry.insert(0, ModFreq)
10685 
10686  if AWG_2X.get() == 1:
10687  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10688  else:
10689  MODperiodvalue = BaseSampleRate/ModFreq
10690 
10691  try:
10692  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
10693  except:
10694  ModIndex = 50.0
10695  AWGADutyCycleEntry.delete(0,"end")
10696  AWGADutyCycleEntry.insert(0, ModIndex)
10697 
10698  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10699  if ModCycles < 1:
10700  ModCycles = 1
10701  RecLength = int(ModCycles * MODperiodvalue)
10702  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10703  RecLength = RecLength + 1
10704  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10705  AWGAwaveform = []
10706  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
10707  if AWG_Amp_Mode.get() == 0:
10708  if AWGAMode.get() == 1: # convert to mA
10709  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10710  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10711  else:
10712  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10713  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10714  else:
10715  if AWGAMode.get() == 1: # convert to mA
10716  amplitude = AWGAAmplvalue/1000.0
10717  offset = AWGAOffsetvalue/1000.0
10718  else:
10719  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10720  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10721  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10722  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10723 #
10724  SplitAWGAwaveform() # if needed
10725  UpdateAwgCont()
10726 #
10728  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10729  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10730  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10731  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10732 
10733  BAWGAAmpl(0)
10734  BAWGAOffset(0)
10735  BAWGAFreq(0)
10736  BAWGAPhase(0)
10737  BAWGADutyCycle(0)
10738 
10739  if AWGAFreqvalue > 0.0:
10740  if AWG_2X.get() == 1:
10741  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10742  else:
10743  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10744  else:
10745  AWGAperiodvalue = 0.0
10746  if AWG_Amp_Mode.get() == 1:
10747  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10748  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10749  else:
10750  MaxV = AWGAOffsetvalue
10751  MinV = AWGAAmplvalue
10752 
10753  PulseWidth = int(AWGADutyCyclevalue*100)
10754  PulseSamples = int(AWGAperiodvalue/PulseWidth)
10755  AWGAwaveform = []
10756  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10757  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10758  # print(v)
10759  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10760  if j >= v:
10761  AWGAwaveform.append(MaxV) # j>=v?1:0
10762  else:
10763  AWGAwaveform.append(MinV) # j>=v?1:0
10765  duty1lab.config(text="PWidth")
10766  UpdateAwgCont()
10767 #
10769  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10770  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10771  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10772  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10773 
10774  BAWGAAmpl(0)
10775  BAWGAOffset(0)
10776  BAWGAFreq(0)
10777  BAWGADutyCycle(0)
10778 
10779  Max_term = int(AWGADutyCyclevalue*100)
10780  if AWG_2X.get() == 1:
10781  TempRate = (BaseSampleRate*2)
10782  else:
10783  TempRate = BaseSampleRate
10784  AWGAwaveform = []
10785  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGAFreqvalue))) # the fundamental
10786  k = 3
10787  while k <= Max_term:
10788  # Add odd harmonics up to max_term
10789  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGAFreqvalue))))
10790  AWGAwaveform = AWGAwaveform + Harmonic
10791  k = k + 2 # skip even numbers
10792  if AWG_Amp_Mode.get() == 0:
10793  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
10794  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
10795  else:
10796  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10797  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10798  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10800  duty1lab.config(text="Harmonics")
10801  BAWGAPhaseDelay()
10802  UpdateAwgCont()
10803 #
10805  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10806  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
10807  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10808  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10809 
10810  BAWGAAmpl(0)
10811  BAWGAOffset(0)
10812  BAWGAFreq(0)
10813  BAWGAPhase(0)
10814  BAWGADutyCycle(0)
10815 
10816  if AWGAFreqvalue > 0.0:
10817  if AWG_2X.get() == 1:
10818  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10819  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10820  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10821  AWGAperiodvalue = AWGAperiodvalue + 1
10822  else:
10823  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10824  SamplesPermS = int(BaseSampleRate/1000) # 100
10825  else:
10826  AWGAperiodvalue = 0.0
10827  if AWG_Amp_Mode.get() == 1:
10828  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10829  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10830  else:
10831  MaxV = AWGAOffsetvalue
10832  MinV = AWGAAmplvalue
10833 
10834  if AWGAPhaseDelay.get() == 0:
10835  if AWGAPhasevalue > 0:
10836  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10837  else:
10838  AWGAdelayvalue = 0.0
10839  elif AWGAPhaseDelay.get() == 1:
10840  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10841 
10842  Cycles = int(AWGADutyCyclevalue*100)
10843  NCycles = -1 * Cycles
10844  AWGAwaveform = []
10845  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGAFreqvalue)))
10846  amplitude = (MaxV-MinV) / 2.0
10847  offset = (MaxV+MinV) / 2.0
10848  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10849  Cycles = int(37500/AWGAperiodvalue)
10850  if Cycles < 1:
10851  Cycles = 1
10852  if Cycles > 1:
10853  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
10854  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
10855  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10857  #BAWGAPhaseDelay()
10858  duty1lab.config(text="Cycles")
10859  BAWGAPhaseDelay()
10860  UpdateAwgCont()
10861 #
10863  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10864  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10865  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10866  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10867  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10868 
10869  BAWGAAmpl(0)
10870  BAWGAOffset(0)
10871  BAWGAFreq(0)
10872  BAWGAPhase(0)
10873  BAWGADutyCycle(0)
10874 
10875  if AWGAFreqvalue > 0.0:
10876  if AWG_2X.get() == 1:
10877  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10878  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10879  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10880  AWGAperiodvalue = AWGAperiodvalue + 1
10881  else:
10882  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10883  SamplesPermS = int(BaseSampleRate/1000) # 100
10884  else:
10885  AWGAperiodvalue = 0.0
10886  if AWG_Amp_Mode.get() == 1:
10887  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10888  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10889  else:
10890  MaxV = AWGAOffsetvalue
10891  MinV = AWGAAmplvalue
10892  AWGAwaveform = []
10893  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
10894  if SlopeValue <= 0:
10895  SlopeValue = 1
10896  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10897  if PulseWidth <=0:
10898  PulseWidth = 1
10899  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
10900  if Remainder <= 0:
10901  Remainder = 1
10902  PulseWidth = PulseWidth - SlopeValue
10903  if PulseWidth <=0:
10904  PulseWidth = 1
10905  StepAmp = (MaxV - MinV)/2
10906  StepOff = (MaxV + MinV)/2
10907  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10908  MidArray = numpy.ones(PulseWidth) * MinV
10909  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
10910  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
10911  if AWGABurstFlag.get() == 1:
10912  TempOneCycle = AWGAwaveform
10913  for i in range(AWGACycles-1):
10914  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10915  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10916  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10918  duty1lab.config(text="%")
10919  phasealab.config(text = "Rise Time")
10920  UpdateAwgCont()
10921 #
10923  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10924  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10925  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10926  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10927  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10928 
10929  BAWGAAmpl(0)
10930  BAWGAOffset(0)
10931  BAWGAFreq(0)
10932  BAWGAPhase(0)
10933  BAWGADutyCycle(0)
10934 
10935  if AWGAFreqvalue > 0.0:
10936  if AWG_2X.get() == 1:
10937  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10938  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10939  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10940  AWGAperiodvalue = AWGAperiodvalue + 1
10941  else:
10942  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10943  SamplesPermS = int(BaseSampleRate/1000) # 100
10944  else:
10945  AWGAperiodvalue = 0.0
10946  if AWG_Amp_Mode.get() == 1:
10947  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10948  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10949  else:
10950  MaxV = AWGAOffsetvalue
10951  MinV = AWGAAmplvalue
10952  AWGAwaveform = []
10953  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
10954  if SlopeValue <= 0:
10955  SlopeValue = 1
10956  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10957  if PulseWidth <=0:
10958  PulseWidth = 1
10959  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
10960  if Remainder <= 0:
10961  Remainder = 1
10962  PulseWidth = PulseWidth - SlopeValue
10963  if PulseWidth <=0:
10964  PulseWidth = 1
10965  StepValue = (MaxV - MinV) / SlopeValue
10966  SampleValue = MinV
10967  for i in range(SlopeValue):
10968  AWGAwaveform.append(SampleValue)
10969  SampleValue = SampleValue + StepValue
10970  for i in range(PulseWidth):
10971  AWGAwaveform.append(MaxV)
10972  for i in range(SlopeValue):
10973  AWGAwaveform.append(SampleValue)
10974  SampleValue = SampleValue - StepValue
10975  for i in range(Remainder):
10976  AWGAwaveform.append(MinV)
10977  if AWGABurstFlag.get() == 1:
10978  TempOneCycle = AWGAwaveform
10979  for i in range(AWGACycles-1):
10980  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10981  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10982  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10984  duty1lab.config(text="%")
10985  phasealab.config(text = "Rise Time")
10986  UpdateAwgCont()
10987 #
10989  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10990  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10991  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10992  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10993  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10994 
10995  BAWGAAmpl(0)
10996  BAWGAOffset(0)
10997  BAWGAFreq(0)
10998  BAWGAPhase(0)
10999 
11000  try:
11001  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11002  except:
11003  AWGADutyCycleEntry.delete(0,"end")
11004  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
11005 
11006  if AWGAFreqvalue > 0.0:
11007  if AWG_2X.get() == 1:
11008  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11009  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11010  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11011  AWGAperiodvalue = AWGAperiodvalue + 1
11012  else:
11013  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11014  SamplesPermS = int(BaseSampleRate/1000) # 100
11015  else:
11016  AWGAperiodvalue = 0.0
11017  if AWG_Amp_Mode.get() == 1:
11018  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11019  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11020  else:
11021  MaxV = AWGAOffsetvalue
11022  MinV = AWGAAmplvalue
11023  AWGAwaveform = []
11024  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11025  if SlopeValue <= 0:
11026  SlopeValue = 1
11027  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
11028  if PulseWidth <=0:
11029  PulseWidth = 1
11030  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
11031  if Remainder <= 0:
11032  Remainder = 1
11033  PulseWidth = PulseWidth - SlopeValue
11034  if PulseWidth <=0:
11035  PulseWidth = 1
11036  StepValue = (MaxV - MinV) / SlopeValue
11037  SampleValue = MinV
11038  for i in range(SlopeValue):
11039  AWGAwaveform.append(SampleValue)
11040  SampleValue = SampleValue + StepValue
11041  for i in range(PulseWidth):
11042  AWGAwaveform.append(MaxV)
11043  for i in range(SlopeValue):
11044  AWGAwaveform.append(SampleValue)
11045  SampleValue = SampleValue - StepValue
11046  for i in range(Remainder):
11047  AWGAwaveform.append(MinV)
11048  if AWGABurstFlag.get() == 1:
11049  TempOneCycle = AWGAwaveform
11050  for i in range(AWGACycles-1):
11051  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11052  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11053  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11055  duty1lab.config(text="Width mS")
11056  phasealab.config(text = "Rise Time")
11057  UpdateAwgCont()
11058 #
11060  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11061  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11062  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11063  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11064  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11065 
11066  BAWGAAmpl(0)
11067  BAWGAOffset(0)
11068  BAWGAFreq(0)
11069  BAWGAPhase(0)
11070  BAWGADutyCycle(0)
11071 
11072  if AWGAFreqvalue > 0.0:
11073  if AWG_2X.get() == 1:
11074  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11075  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11076  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11077  AWGAperiodvalue = AWGAperiodvalue + 1
11078  else:
11079  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11080  SamplesPermS = int(BaseSampleRate/1000) # 100
11081  else:
11082  AWGAperiodvalue = 0.0
11083  if AWG_Amp_Mode.get() == 1:
11084  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11085  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11086  else:
11087  MaxV = AWGAOffsetvalue
11088  MinV = AWGAAmplvalue
11089  AWGAwaveform = []
11090  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11091  if SlopeValue <= 0:
11092  SlopeValue = 1
11093  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11094  if PulseWidth <=0:
11095  PulseWidth = 1
11096  Remainder = int(AWGAperiodvalue - PulseWidth)
11097  if Remainder <= 0:
11098  Remainder = 1
11099  PulseWidth = PulseWidth - SlopeValue
11100  if PulseWidth <=0:
11101  PulseWidth = 1
11102  StepValue = (MaxV - MinV) / SlopeValue
11103  SampleValue = MinV
11104  for i in range(SlopeValue):
11105  AWGAwaveform.append(SampleValue)
11106  SampleValue = SampleValue + StepValue
11107  for i in range(PulseWidth):
11108  AWGAwaveform.append(MaxV)
11109  for i in range(Remainder):
11110  AWGAwaveform.append(MinV)
11111  if AWGABurstFlag.get() == 1:
11112  TempOneCycle = AWGAwaveform
11113  for i in range(AWGACycles-1):
11114  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11115  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11116  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11118  duty1lab.config(text="%")
11119  phasealab.config(text = "Slope Time")
11120  UpdateAwgCont()
11121 #
11123  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
11124  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11125  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11126  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11127  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11128 
11129  BAWGAAmpl(0)
11130  BAWGAOffset(0)
11131  BAWGAFreq(0)
11132  BAWGAPhase(0)
11133  BAWGADutyCycle(0)
11134 
11135  if AWGAFreqvalue > 0.0:
11136  if AWG_2X.get() == 1:
11137  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11138  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11139  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11140  AWGAperiodvalue = AWGAperiodvalue + 1
11141  else:
11142  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11143  SamplesPermS = int(BaseSampleRate/1000) # 100
11144  else:
11145  AWGAperiodvalue = 0.0
11146  if AWG_Amp_Mode.get() == 1:
11147  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11148  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11149  else:
11150  MaxV = AWGAOffsetvalue
11151  MinV = AWGAAmplvalue
11152  #
11153  if AWGAPhaseDelay.get() == 0:
11154  if AWGAPhasevalue > 0:
11155  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11156  else:
11157  AWGAdelayvalue = 0.0
11158  elif AWGAPhaseDelay.get() == 1:
11159  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11160  #
11161  AWGAwaveform = []
11162  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11163  if PulseWidth <=0:
11164  PulseWidth = 1
11165  Remainder = int(AWGAperiodvalue - PulseWidth)
11166  if Remainder <= 0:
11167  Remainder = 1
11168  UpStepValue = (MaxV - MinV) / PulseWidth
11169  DownStepValue = (MaxV - MinV) / Remainder
11170  SampleValue = MinV
11171  for i in range(PulseWidth):
11172  AWGAwaveform.append(SampleValue)
11173  SampleValue = SampleValue + UpStepValue
11174  for i in range(Remainder):
11175  AWGAwaveform.append(SampleValue)
11176  SampleValue = SampleValue - DownStepValue
11177  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11178  if AWGABurstFlag.get() == 1:
11179  TempOneCycle = AWGAwaveform
11180  for i in range(AWGACycles-1):
11181  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11182  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11183  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11185  BAWGAPhaseDelay()
11186  duty1lab.config(text = "Symmetry")
11187  BAWGAPhaseDelay()
11188  UpdateAwgCont()
11189 #
11191  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11192  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
11193  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11194  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11195  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11196 
11197  BAWGAAmpl(0)
11198  BAWGAOffset(0)
11199  BAWGAFreq(0)
11200  BAWGAPhase(0)
11201  BAWGADutyCycle(0)
11202 
11203  if AWGAFreqvalue > 0.0:
11204  if AWG_2X.get() == 1:
11205  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11206  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11207  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11208  AWGAperiodvalue = AWGAperiodvalue + 1
11209  else:
11210  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11211  SamplesPermS = int(BaseSampleRate/1000) # 100
11212  else:
11213  AWGAperiodvalue = 0.0
11214  if AWG_Amp_Mode.get() == 1:
11215  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11216  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11217  else:
11218  MaxV = AWGAOffsetvalue
11219  MinV = AWGAAmplvalue
11220  AWGAwaveform = []
11221  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
11222  if AWGAPhaseDelay.get() == 0:
11223  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
11224  elif AWGAPhaseDelay.get() == 1:
11225  DelayValue = int(AWGAPhasevalue*SamplesPermS)
11226  for i in range(DelayValue-PulseWidth):
11227  AWGAwaveform.append((MinV+MaxV)/2.0)
11228  for i in range(PulseWidth):
11229  AWGAwaveform.append(MaxV)
11230  for i in range(PulseWidth):
11231  AWGAwaveform.append(MinV)
11232  DelayValue = int(AWGAperiodvalue-DelayValue)
11233  for i in range(DelayValue-PulseWidth):
11234  AWGAwaveform.append((MinV+MaxV)/2.0)
11235  if AWGABurstFlag.get() == 1:
11236  TempOneCycle = AWGAwaveform
11237  for i in range(AWGACycles-1):
11238  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11239  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11240  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11242  duty1lab.config(text = "Duty Cycle")
11243  BAWGAPhaseDelay()
11244  UpdateAwgCont()
11245 
11247  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11248  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11249  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11250  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11251  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11252 
11253  BAWGAAmpl(0)
11254  BAWGAOffset(0)
11255  BAWGAFreq(0)
11256 
11257  if AWGAFreqvalue > 0.0:
11258  if AWG_2X.get() == 1:
11259  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11260  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11261  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11262  AWGAperiodvalue = AWGAperiodvalue + 1
11263  else:
11264  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11265  SamplesPermS = int(BaseSampleRate/1000) # 100
11266  else:
11267  AWGAperiodvalue = 0.0
11268  if AWG_Amp_Mode.get() == 1:
11269  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11270  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11271  else:
11272  if AWGAAmplvalue > AWGAOffsetvalue:
11273  MinV = AWGAOffsetvalue
11274  MaxV = AWGAAmplvalue
11275  else:
11276  MaxV = AWGAOffsetvalue
11277  MinV = AWGAAmplvalue
11278  AWGAwaveform = []
11279  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
11280  Mid = (MaxV+MinV)/2.0
11281  if AWGABurstFlag.get() == 1:
11282  TempOneCycle = AWGAwaveform
11283  for i in range(AWGACycles-1):
11284  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11285  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11286  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11288  BAWGAPhaseDelay()
11289  UpdateAwgCont()
11290 
11292  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11293  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11294  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11295  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11296  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11297 
11298  BAWGAAmpl(0)
11299  BAWGAOffset(0)
11300  BAWGAFreq(0)
11301 
11302  if AWGAFreqvalue > 0.0:
11303  if AWG_2X.get() == 1:
11304  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11305  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11306  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11307  AWGAperiodvalue = AWGAperiodvalue + 1
11308  else:
11309  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11310  SamplesPermS = int(BaseSampleRate/1000) # 100
11311  else:
11312  AWGAperiodvalue = 0.0
11313  if AWG_Amp_Mode.get() == 1:
11314  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11315  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11316  else:
11317  if AWGAAmplvalue > AWGAOffsetvalue:
11318  MinV = AWGAOffsetvalue
11319  MaxV = AWGAAmplvalue
11320  else:
11321  MaxV = AWGAOffsetvalue
11322  MinV = AWGAAmplvalue
11323  AWGAwaveform = []
11324  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
11325  Mid = (MaxV+MinV)/2.0
11326  if AWGABurstFlag.get() == 1:
11327  TempOneCycle = AWGAwaveform
11328  for i in range(AWGACycles-1):
11329  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11330  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11331  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11333  BAWGAPhaseDelay()
11334  UpdateAwgCont()
11335 
11337  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
11338  global EnableScopeOnly, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11339 
11340  if AWGAMode.get() == 0: # Source Voltage measure current mode
11341  label_txt = "SVMI"
11342  elif AWGAMode.get() == 1: # Source current measure voltage mode
11343  label_txt = "SIMV"
11344  elif AWGAMode.get() == 2: # High impedance mode
11345  label_txt = "Hi-Z"
11346  if AWGAIOMode.get() > 0: # Split Input / Output mode
11347  if HWRevOne == "D":
11348  if AWGAMode.get() == 0:
11349  AWGAMode.set(1)
11350  CHA.set_mode('i') # channel must be in source current mode for rev D boards
11351  label_txt = "SIMV"
11352  label_txt = label_txt + " Split I/O"
11353  if EnableScopeOnly == 0:
11354  label_txt = label_txt + " Mode"
11355  AWGAModeLabel.config(text = label_txt ) # change displayed value
11356  ReMakeAWGwaves()
11357  #UpdateAwgCont()
11358 
11360  global AWGAAmplvalue, AWGAOffsetvalue, EnableScopeOnly
11361  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
11362  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
11363  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
11364  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11365  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
11366  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11367 
11368  BAWGAAmpl(0)
11369  BAWGAOffset(0)
11370  BAWGAFreq(0)
11371  BAWGAPhase(0)
11372  BAWGADutyCycle(0)
11373  BAWGAShape()
11374 
11375  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
11376  amp1lab.config(text = "Min Ch A" ) # change displayed value
11377  off1lab.config(text = "Max Ch A" ) # change displayed value
11378  else:
11379  amp1lab.config(text = "Amp Ch A" )
11380  off1lab.config(text = "Off Ch A" )
11381 
11382  if AWGAFreqvalue > 0.0:
11383  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11384  else:
11385  AWGAperiodvalue = 0.0
11386 
11387  if AWGAPhaseDelay.get() == 0:
11388  if AWGAWave == 'square':
11389  AWGAPhasevalue = AWGAPhasevalue + 270.0
11390  if AWGAPhasevalue > 359:
11391  AWGAPhasevalue = AWGAPhasevalue - 360
11392  if AWGAPhasevalue > 0:
11393  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11394  else:
11395  AWGAdelayvalue = 0.0
11396  elif AWGAPhaseDelay.get() == 1:
11397  AWGAdelayvalue = AWGAPhasevalue * 100
11398 
11399  if AWGATerm.get() == 0: # Open termination
11400  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11401  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11402  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
11403  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11404  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
11405  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
11406  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
11407  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11408 
11409  if AWGAWave == 'dc':
11410  if AWG_2X.get() == 2:
11411  AWGAWave == 'arbitrary'
11412  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11413  else:
11414  if AWGAMode.get() == 0: # Source Voltage measure current mode
11415  if AWGAIOMode.get() == 0:
11416  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11417  else:
11418  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11419  CHA.constant(AWGAOffsetvalue)
11420  #
11421  if AWGAMode.get() == 1: # Source current measure voltage mode
11422  if AWGAIOMode.get() == 0:
11423  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11424  else:
11425  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11426  CHA.constant(AWGAOffsetvalue/1000)
11427  #
11428  if AWGAMode.get() == 2: # High impedance mode
11429  if AWGAIOMode.get() == 0:
11430  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11431  else:
11432  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11433  #
11434  if AWGAIOMode.get() > 0: # Split Input / Output mode
11435  if HWRevOne == "D":
11436  AWGAMode.set(1)
11437  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11438 #
11439  else:
11440  if AWGAMode.get() == 0: # Source Voltage measure current mode
11441  if AWGAIOMode.get() == 0:
11442  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11443  else:
11444  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11445  if AWGAMode.get() == 1: # Source current measure voltage mode
11446  if AWGAIOMode.get() == 0:
11447  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11448  else:
11449  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11450  AWGAOffsetvalue = AWGAOffsetvalue/1000
11451  AWGAAmplvalue = AWGAAmplvalue/1000
11452  if AWGAMode.get() == 2: # High impedance mode
11453  if AWGAIOMode.get() == 0:
11454  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11455  else:
11456  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11457  else:
11458  if AWG_Amp_Mode.get() == 1:
11459  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11460  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11461  else:
11462  MaxV = AWGAOffsetvalue
11463  MinV = AWGAAmplvalue
11464  try:
11465  if AWGAWave == 'sine':
11466  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11467  elif AWGAWave == 'triangle':
11468  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11469  elif AWGAWave == 'sawtooth':
11470  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11471  elif AWGAWave == 'square':
11472  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
11473  elif AWGAWave == 'stairstep':
11474  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11475  elif AWGAWave == 'arbitrary':
11476  if EnableScopeOnly == 0:
11477  AddAWGANoise()
11478  if AWGSync.get() == 0:
11479  AWGARepeatFlag.set(1)
11480  if AWG_2X.get() == 2:
11481  AWGAWave == 'arbitrary'
11482  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11483  else:
11484  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
11485  except:
11486  donothing()
11487  if AWGAIOMode.get() > 0: # Split Input / Output mode
11488  if HWRevOne == "D":
11489  AWGAMode.set(1)
11490  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11491 #
11493  global AWG_2X, AWGB2X, AWGAwaveform
11494  global AWGANoiseEntry, AWGAsbnoise, AWGANoisevalue
11495 
11496  if AWGAsbnoise.get() == "None":
11497  return
11498  else:
11499  try:
11500  AWGANoisevalue = float(eval(AWGANoiseEntry.get()))
11501  except:
11502  AWGANoiseEntry.delete(0,"end")
11503  AWGANoiseEntry.insert(0, AWGANoisevalue)
11504  if AWGANoisevalue == 0.0:
11505  return
11506  AWGANoiseform = []
11507  if AWGAsbnoise.get() == "Gaussian":
11508  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGAwaveform))
11509  else:
11510  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGAwaveform))
11511  AWGAwaveform = AWGAwaveform + AWGANoiseform
11512  if AWG_2X.get() == 2:
11513  if AWGAsbnoise.get() == "Gaussian":
11514  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGB2X))
11515  else:
11516  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGB2X))
11517  AWGB2X = AWGB2X + AWGANoiseform
11518 
11520  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
11521  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
11522  global BisCompA, AWGAWave
11523 
11524  # if BisCompA.get() == 1:
11525  # sawp Min and Max values
11526  if AWGAWave == 'dc':
11527  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11528  AWGBOffsetvalue = 2.5 - (float(eval(AWGAOffsetEntry.get()))-2.5)
11529  AWGBAmplEntry.delete(0,"end")
11530  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11531  AWGBOffsetEntry.delete(0,"end")
11532  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11533  else:
11534  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11535  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
11536  AWGBAmplEntry.delete(0,"end")
11537  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
11538  AWGBOffsetEntry.delete(0,"end")
11539  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
11540  # copy everything else
11541  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
11542  AWGBFreqEntry.delete(0,"end")
11543  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11544  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
11545  AWGBPhaseEntry.delete(0,"end")
11546  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11547  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11548  AWGBDutyCycleEntry.delete(0,"end")
11549  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11550  AWGBShape.set(AWGAShape.get())
11551  #
11552 # ReMakeAWGwaves()
11553 # UpdateAwgCont()
11554 #
11555 # AWG B functions
11557  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11558 
11559  if AWGBBurstFlag.get() == 1:
11560  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
11561  if (AWGBCyclesString == None): # If Cancel pressed, then None
11562  return
11563  AWGBCycles = int(AWGBCyclesString)
11564  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
11565  if (AWGBDelayString == None): # If Cancel pressed, then None
11566  return
11567  AWGBBurstDelay = float(AWGBDelayString)
11568  ReMakeAWGwaves()
11569 #
11570 def BAWGBAmpl(temp):
11571  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11572  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11573 
11574  try:
11575  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
11576  except:
11577  AWGBAmplEntry.delete(0,"end")
11578  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11579  #
11580  if AWGBMode.get() == 0: # Source Voltage measure current mode
11581  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
11582  if AWGBAmplvalue > 5.00:
11583  AWGBAmplvalue = 5.00
11584  AWGBAmplEntry.delete(0,"end")
11585  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11586  if AWGBAmplvalue < 0.00:
11587  AWGBAmplvalue = 0.00
11588  AWGBAmplEntry.delete(0,"end")
11589  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11590  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11591  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
11592  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
11593  AWGBAmplEntry.delete(0,"end")
11594  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11595  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
11596  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
11597  AWGBAmplEntry.delete(0,"end")
11598  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11599  elif AWGBMode.get() == 1: # Source current measure voltage mode
11600  if AWGBAmplvalue > 200.00:
11601  AWGBAmplvalue = 200.00
11602  AWGBAmplEntry.delete(0,"end")
11603  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11604  if AWGBAmplvalue < -200.00:
11605  AWGBAmplvalue = -200.00
11606  AWGBAmplEntry.delete(0,"end")
11607  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11608 #
11609 def BAWGBOffset(temp):
11610  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11611  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11612 
11613  try:
11614  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
11615  except:
11616  AWGBOffsetEntry.delete(0,"end")
11617  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11618  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
11619  if AWGBMode.get() == 0: # Source Voltage measure current mode
11620  if AWGBOffsetvalue > 5.00:
11621  AWGBOffsetvalue = 5.00
11622  AWGBOffsetEntry.delete(0,"end")
11623  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11624  if AWGBOffsetvalue < 0.00:
11625  AWGBOffsetvalue = 0.00
11626  AWGBOffsetEntry.delete(0,"end")
11627  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11628  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11629  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
11630  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
11631  AWGBOffsetEntry.delete(0,"end")
11632  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11633  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
11634  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
11635  AWGBOffsetEntry.delete(0,"end")
11636  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11637  if AWGBMode.get() == 1: # Source current measure voltage mode
11638  if AWGBOffsetvalue > 200.00:
11639  AWGBOffsetvalue = 200.00
11640  AWGBOffsetEntry.delete(0,"end")
11641  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11642  if AWGBOffsetvalue < -200.00:
11643  AWGBOffsetvalue = -200.00
11644  AWGBOffsetEntry.delete(0,"end")
11645  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11646 #
11647 def BAWGBFreq(temp):
11648  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
11649  global BodeScreenStatus, BodeDisp, AWGRecLength
11650 
11651  try:
11652  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
11653  except:
11654  AWGBFreqEntry.delete(0,"end")
11655  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11656  if AWG_2X.get() == 2:
11657  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
11658  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
11659  AWGBFreqvalue = 90000
11660  AWGBFreqEntry.delete(0,"end")
11661  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11662  else:
11663  if AWGBFreqvalue > 50000: # max freq is 50KHz
11664  AWGBFreqvalue = 50000
11665  AWGBFreqEntry.delete(0,"end")
11666  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11667  else:
11668  if AWGBFreqvalue > 25000: # max freq is 25KHz
11669  AWGBFreqvalue = 25000
11670  AWGBFreqEntry.delete(0,"end")
11671  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11672  if AWGBFreqvalue < 4.0:
11673  AWGRecLength = 32768*2
11674  else:
11675  AWGRecLength = 32768
11676  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
11677  AWGBFreqvalue = 10
11678  AWGBFreqEntry.delete(0,"end")
11679  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11680  # UpdateAWGB()
11681 
11683  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11684 
11685  if AWGBPhaseDelay.get() == 1:
11686  AWGBPhaseDelay.set(0)
11687  awgbph.configure(text="Phase")
11688  phaseblab.configure(text="Deg")
11689  elif AWGBPhaseDelay.get() == 0:
11690  AWGBPhaseDelay.set(1)
11691  awgbph.configure(text="Delay")
11692  phaseblab.configure(text="mSec")
11693 
11695  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11696 
11697  if AWGBPhaseDelay.get() == 0:
11698  phaseblab.configure(text="Deg")
11699  awgbph.configure(text="Phase")
11700  elif AWGBPhaseDelay.get() == 1:
11701  phaseblab.configure(text="mSec")
11702  awgbph.configure(text="Delay")
11703 
11704 def BAWGBPhase(temp):
11705  global AWGBPhaseEntry, AWGBPhasevalue
11706 
11707  try:
11708  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
11709  except:
11710  AWGBPhaseEntry.delete(0,"end")
11711  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11712 
11713  if AWGBPhasevalue > 360: # max phase is 360 degrees
11714  AWGBPhasevalue = 360
11715  AWGBPhaseEntry.delete(0,"end")
11716  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11717  if AWGBPhasevalue < 0: # min phase is 0 degrees
11718  AWGBPhasevalue = 0
11719  AWGBPhaseEntry.delete(0,"end")
11720  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11721 
11722 def BAWGBDutyCycle(temp):
11723  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
11724 
11725  try:
11726  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
11727  except:
11728  AWGBDutyCycleEntry.delete(0,"end")
11729  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11730 
11731  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
11732  AWGBDutyCyclevalue = 1
11733  AWGBDutyCycleEntry.delete(0,"end")
11734  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
11735  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
11736  AWGBDutyCyclevalue = 0
11737  AWGBDutyCycleEntry.delete(0,"end")
11738  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11739  # UpdateAWGB()
11740 
11742  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
11743 
11744  if AWGBShape.get() == 0:
11745  AWGBWave = 'dc'
11746  duty2lab.config(text="%")
11747  BAWGBPhaseDelay()
11748  if AWGBShape.get() == 1:
11749  AWGBWave = 'sine'
11750  duty2lab.config(text="%")
11751  BAWGBPhaseDelay()
11752  if AWGBShape.get() == 2:
11753  AWGBWave = 'triangle'
11754  duty2lab.config(text="%")
11755  BAWGBPhaseDelay()
11756  if AWGBShape.get() == 3:
11757  AWGBWave = 'sawtooth'
11758  duty2lab.config(text="%")
11759  BAWGBPhaseDelay()
11760  if AWGBShape.get() == 4:
11761  AWGBWave = 'square'
11762  duty2lab.config(text="%")
11763  BAWGBPhaseDelay()
11764  if AWGBShape.get() == 5:
11765  AWGBWave = 'stairstep'
11766  duty2lab.config(text="%")
11767  BAWGBPhaseDelay()
11768  if AWGBShape.get() > 5:
11769  AWGBWave = 'arbitrary'
11770  if AWG_2X.get() == 1:
11771  CHB.mode = CHA.mode
11772  AWGBWave = 'arbitrary'
11773  # UpdateAWGB()
11774 
11776  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
11777 
11778  # Read values from CVS file
11779  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11780  AWGBcsvFile = filename
11781  AWGBLoadCSV()
11782 #
11784  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile, AWGBOffsetvalue
11785 
11786  BAWGBOffset(0)
11787  try:
11788  CSVFile = open(AWGBcsvFile)
11789  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
11790  CSVFile.seek(0)
11791  #csv_f = csv.reader(CSVFile, dialect)
11792  csv_f = csv.reader(CSVFile, csv.excel)
11793  except:
11794  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11795  AWGBwaveform = []
11796  ColumnNum = 0
11797  ColumnSel = 0
11798  RowNum = 0
11799  for row in csv_f:
11800  if len(row) > 1 and ColumnSel == 0:
11801  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
11802  ColumnNum = int(RequestColumn) - 1
11803  ColumnLen = str(len(row))
11804  ColumnSel = 1
11805  try:
11806  colnum = 0
11807  for col in row:
11808  if colnum == ColumnNum:
11809  AWGBwaveform.append(float(col))
11810  colnum += 1
11811  except:
11812  print( 'skipping non-numeric row', RowNum)
11813  RowNum += 1
11814  AWGBwaveform = numpy.array(AWGBwaveform)
11815  AWGBwaveform = AWGBwaveform + AWGBOffsetvalue # add DC offset from Max entry
11817  CSVFile.close()
11818  UpdateAwgCont()
11819 
11820 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
11822  global AWG_2X, AWGB2X, AWGBwaveform
11823  global AWGFiltB, AWGFiltBCoef
11824 
11825  # check if AWG digital filter box checked
11826  if AWGFiltB.get() == 1:
11827  BufLen = len(AWGBwaveform)
11828  CoefLen = len(AWGFiltBCoef)/2
11829  AWGBwaveform = numpy.pad(AWGBwaveform, (CoefLen,CoefLen), 'wrap')
11830  AWGBwaveform = numpy.convolve(AWGBwaveform, AWGFiltBCoef)
11831  AWGBwaveform = numpy.roll(AWGBwaveform, -CoefLen)
11832  AWGBwaveform = AWGBwaveform[CoefLen:BufLen+CoefLen]
11833 
11834  if AWG_2X.get() == 2:
11835  Tempwaveform = []
11836  AWGB2X = []
11837  AWGB2X = AWGBwaveform[::2] # even numbered samples
11838  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
11839  AWGBwaveform = Tempwaveform
11840 #
11842  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11843  global AWG_2X, AWGA2X
11844 
11845 # Read values from WAV file
11846  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
11847  AWGBwavFile = filename
11848  AWGBLoadWAV()
11849 #
11851  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11852  global AWG_2X, AWGA2X
11853 
11854  try:
11855  spf = wave.open(AWGBwavFile,'r')
11856  except:
11857  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11858  AWGBwaveform = []
11859  #If Stereo
11860  if spf.getnchannels() == 2:
11861  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
11862  return()
11863  #Extract Raw Audio from Wav File
11864  Length = spf.getnframes()
11865  if Length > 90000: # limit to first 90K samples
11866  Length = 90000
11867  signal = spf.readframes(Length)
11868  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
11869  # offset and scale for 0 5 V range
11870  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
11871  AWGBwaveform = numpy.array(AWGBwaveform)
11873  spf.close()
11874  UpdateAwgCont()
11875 
11877  global AWGBwaveform, AWGBLength, awgwindow
11878 
11879  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11880  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
11881 
11883  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11884  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11885  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11886  global DFiltACoef, DFiltBCoef, AWGBShapeLabel, AWGBLength
11887  global AWG_2X, AWGA2X
11888 
11889  TempString = AWGBMathString
11890  AWGBShapeLabel.config(text = "Math" ) # change displayed value
11891  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
11892  if (AWGBMathString == None): # If Cancel pressed, then None
11893  AWGBMathString = TempString
11894  return
11895  try:
11896  AWGBwaveform = eval(AWGBMathString)
11897  except:
11898  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
11899  AWGBwaveform = numpy.array(AWGBwaveform)
11901  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11902  UpdateAwgCont()
11903 #
11905  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11906  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11907  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11908  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
11909  global AWG_2X, AWGA2X
11910 
11911  AWGBwaveform = eval(AWGBMathString)
11912  AWGBwaveform = numpy.array(AWGBwaveform)
11914  UpdateAwgCont()
11915 #
11917  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
11918  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11919  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, duty2lab
11920  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11921 
11922  Max_term = int(AWGBDutyCyclevalue*100)
11923 
11924  BAWGBAmpl(0)
11925  BAWGBOffset(0)
11926  BAWGBFreq(0)
11927  if AWG_2X.get() == 1:
11928  TempRate = (BaseSampleRate*2)
11929  else:
11930  TempRate = BaseSampleRate
11931  AWGBwaveform = []
11932  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGBFreqvalue))) # the fundamental
11933  k = 3
11934  while k <= Max_term:
11935  # Add odd harmonics up to max_term
11936  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGBFreqvalue))))
11937  AWGBwaveform = AWGBwaveform + Harmonic
11938  k = k + 2 # skip even numbers
11939  if AWG_Amp_Mode.get() == 0:
11940  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
11941  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
11942  else:
11943  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
11944  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
11945  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
11947  duty2lab.config(text="Harmonics")
11948  BAWGBPhaseDelay()
11949  UpdateAwgCont()
11950 #
11952  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
11953  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
11954  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
11955  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11956 
11957  BAWGBAmpl(0)
11958  BAWGBOffset(0)
11959  BAWGBFreq(0)
11960  BAWGBPhase(0)
11961  BAWGBDutyCycle(0)
11962  MinFreq = float(AWGSAMPLErate)/float(AWGRecLength)
11963  if AWGBFreqvalue < MinFreq: # if frequency is less than 1 cycle in record length Hz use libsmu sine function
11964  AWGBShape.set(1)
11965  BAWGBShape()
11966  UpdateAwgCont()
11967  return
11968 
11969  if AWGBFreqvalue > 0.0:
11970  if AWG_2X.get() == 2:
11971  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11972  else:
11973  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11974  else:
11975  AWGBperiodvalue = 10.0
11976 
11977  if AWGBPhaseDelay.get() == 0:
11978  if AWGBPhasevalue > 0:
11979  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
11980  else:
11981  AWGBdelayvalue = 0.0
11982  elif AWGBPhaseDelay.get() == 1:
11983  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
11984  Cycles = int(AWGRecLength/AWGBperiodvalue)
11985  if Cycles < 1:
11986  Cycles = 1
11987  RecLength = int(Cycles * AWGBperiodvalue)
11988  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11989  RecLength = RecLength + 1
11990  AWGBwaveform = []
11991  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11992 
11993  if AWG_Amp_Mode.get() == 0:
11994  if AWGBMode.get() == 1: # convert to mA
11995  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
11996  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
11997  else:
11998  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
11999  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
12000  else:
12001  if AWGBMode.get() == 1: # convert to mA
12002  amplitude = AWGBAmplvalue/1000.0
12003  offset = AWGBOffsetvalue/1000.0
12004  else:
12005  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
12006  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
12007  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12008  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12009  #
12010  if AWG_2X.get() == 2:
12011  Tempwaveform = []
12012  AWGB2X = []
12013  AWGB2X = AWGBwaveform[::2] # even numbered samples
12014  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
12015  AWGBwaveform = Tempwaveform
12016  BAWGBPhaseDelay()
12017  duty2lab.config(text="%")
12018  UpdateAwgCont()
12019 #
12021  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
12022  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12023  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12024  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12025 
12026  BAWGBAmpl(0)
12027  BAWGBOffset(0)
12028  BAWGBFreq(0)
12029  BAWGBPhase(0)
12030  BAWGBDutyCycle(0)
12031 
12032  if AWGBFreqvalue > 0.0:
12033  if AWG_2X.get() == 2:
12034  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12035  else:
12036  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12037  else:
12038  AWGBperiodvalue = 0.0
12039  if AWG_Amp_Mode.get() == 1:
12040  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12041  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12042  else:
12043  MaxV = AWGBOffsetvalue
12044  MinV = AWGBAmplvalue
12045 
12046  PulseWidth = int(AWGBDutyCyclevalue*100)
12047  PulseSamples = int(AWGBperiodvalue/PulseWidth)
12048  AWGBwaveform = []
12049  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
12050  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
12051  # print(v)
12052  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
12053  if j >= v:
12054  AWGBwaveform.append(MaxV) # j>=v?1:0
12055  else:
12056  AWGBwaveform.append(MinV) # j>=v?1:0
12058  duty2lab.config(text="PWidth")
12059  UpdateAwgCont()
12060 #
12062  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12063  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
12064  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12065  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12066 
12067  BAWGBAmpl(0)
12068  BAWGBOffset(0)
12069  BAWGBFreq(0)
12070  BAWGBPhase(0)
12071  BAWGBDutyCycle(0)
12072 
12073  if AWGBFreqvalue > 0.0:
12074  if AWG_2X.get() == 1:
12075  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
12076  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12077  AWGBperiodvalue = AWGBperiodvalue + 1
12078  else:
12079  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12080  else:
12081  AWGBperiodvalue = 0.0
12082  if AWG_Amp_Mode.get() == 1:
12083  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12084  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12085  else:
12086  MaxV = AWGBOffsetvalue
12087  MinV = AWGBAmplvalue
12088 
12089  if AWGBPhaseDelay.get() == 0:
12090  if AWGBPhasevalue > 0:
12091  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12092  else:
12093  AWGBdelayvalue = 0.0
12094  elif AWGBPhaseDelay.get() == 1:
12095  AWGBdelayvalue = AWGBPhasevalue * SAMPLErate / 1000
12096 
12097  Cycles = int(AWGBDutyCyclevalue*100)
12098  NCycles = -1 * Cycles
12099  AWGBwaveform = []
12100  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGBFreqvalue)))
12101  amplitude = (MaxV-MinV) / 2.0
12102  offset = (MaxV+MinV) / 2.0
12103  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12104  Cycles = int(37500/AWGBperiodvalue)
12105  if Cycles < 1:
12106  Cycles = 1
12107  if Cycles > 1:
12108  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
12109  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
12110  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12112  duty2lab.config(text="Cycles")
12113  BAWGBPhaseDelay()
12114  UpdateAwgCont()
12115 #
12117  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12118  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12119  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12120  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12121  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12122  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12123 
12124  BAWGBAmpl(0)
12125  BAWGBOffset(0)
12126  BAWGBFreq(0)
12127  BAWGBPhase(0)
12128  BAWGBDutyCycle(0)
12129 
12130  if AWGBFreqvalue > 0.0:
12131  if AWG_2X.get() == 2:
12132  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12133  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12134  else:
12135  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12136  SamplesPermS = int(BaseSampleRate/1000) # 100
12137  else:
12138  AWGBperiodvalue = 0.0
12139  if AWG_Amp_Mode.get() == 1:
12140  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12141  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12142  else:
12143  MaxV = AWGBOffsetvalue
12144  MinV = AWGBAmplvalue
12145  AWGBwaveform = []
12146  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12147  if SlopeValue <= 0:
12148  SlopeValue = 1
12149  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12150  if PulseWidth <=0:
12151  PulseWidth = 1
12152  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
12153  if Remainder <= 0:
12154  Remainder = 1
12155  PulseWidth = PulseWidth - SlopeValue
12156  if PulseWidth <=0:
12157  PulseWidth = 1
12158  StepAmp = (MaxV - MinV)/2
12159  StepOff = (MaxV + MinV)/2
12160  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
12161  MidArray = numpy.ones(PulseWidth) * MinV
12162  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
12163  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
12164  if AWGBBurstFlag.get() == 1:
12165  TempOneCycle = AWGBwaveform
12166  for i in range(AWGBCycles-1):
12167  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12168  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12169  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12171  duty2lab.config(text="%")
12172  phaseblab.config(text = "Rise Time")
12173  UpdateAwgCont()
12174 #
12176  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12177  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12178  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12179  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12180  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12181  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12182 
12183  BAWGBAmpl(0)
12184  BAWGBOffset(0)
12185  BAWGBFreq(0)
12186  BAWGBPhase(0)
12187  BAWGBDutyCycle(0)
12188 
12189  if AWGBFreqvalue > 0.0:
12190  if AWG_2X.get() == 2:
12191  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12192  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12193  else:
12194  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12195  SamplesPermS = int(BaseSampleRate/1000) # 100
12196  else:
12197  AWGBperiodvalue = 0.0
12198  if AWG_Amp_Mode.get() == 1:
12199  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12200  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12201  else:
12202  MaxV = AWGBOffsetvalue
12203  MinV = AWGBAmplvalue
12204  AWGBwaveform = []
12205  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12206  if SlopeValue <= 0:
12207  SlopeValue = 1
12208  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12209  if PulseWidth <=0:
12210  PulseWidth = 1
12211  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12212  if Remainder <= 0:
12213  Remainder = 1
12214  PulseWidth = PulseWidth - SlopeValue
12215  if PulseWidth <=0:
12216  PulseWidth = 1
12217  StepValue = (MaxV - MinV) / SlopeValue
12218  SampleValue = MinV
12219  for i in range(SlopeValue):
12220  AWGBwaveform.append(SampleValue)
12221  SampleValue = SampleValue + StepValue
12222  for i in range(PulseWidth):
12223  AWGBwaveform.append(MaxV)
12224  for i in range(SlopeValue):
12225  AWGBwaveform.append(SampleValue)
12226  SampleValue = SampleValue - StepValue
12227  for i in range(Remainder):
12228  AWGBwaveform.append(MinV)
12229  if AWGBBurstFlag.get() == 1:
12230  TempOneCycle = AWGBwaveform
12231  for i in range(AWGBCycles-1):
12232  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12233  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12234  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12236  duty2lab.config(text="%")
12237  phaseblab.config(text = "Rise Time")
12238  UpdateAwgCont()
12239 #
12241  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12242  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12243  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12244  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12245  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12246  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12247 
12248  BAWGBAmpl(0)
12249  BAWGBOffset(0)
12250  BAWGBFreq(0)
12251  BAWGBPhase(0)
12252 
12253  try:
12254  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
12255  except:
12256  AWGBDutyCycleEntry.delete(0,"end")
12257  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12258 
12259  if AWGBFreqvalue > 0.0:
12260  if AWG_2X.get() == 2:
12261  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12262  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12263  else:
12264  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12265  SamplesPermS = int(BaseSampleRate/1000) # 100
12266  else:
12267  AWGBperiodvalue = 0.0
12268  if AWG_Amp_Mode.get() == 1:
12269  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12270  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12271  else:
12272  MaxV = AWGBOffsetvalue
12273  MinV = AWGBAmplvalue
12274  AWGBwaveform = []
12275  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12276  if SlopeValue <= 0:
12277  SlopeValue = 1
12278  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
12279  if PulseWidth <=0:
12280  PulseWidth = 1
12281  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12282  if Remainder <= 0:
12283  Remainder = 1
12284  PulseWidth = PulseWidth - SlopeValue
12285  if PulseWidth <=0:
12286  PulseWidth = 1
12287  StepValue = (MaxV - MinV) / SlopeValue
12288  SampleValue = MinV
12289  for i in range(SlopeValue):
12290  AWGBwaveform.append(SampleValue)
12291  SampleValue = SampleValue + StepValue
12292  for i in range(PulseWidth):
12293  AWGBwaveform.append(MaxV)
12294  for i in range(SlopeValue):
12295  AWGBwaveform.append(SampleValue)
12296  SampleValue = SampleValue - StepValue
12297  for i in range(Remainder):
12298  AWGBwaveform.append(MinV)
12299  if AWGBBurstFlag.get() == 1:
12300  TempOneCycle = AWGBwaveform
12301  for i in range(AWGBCycles-1):
12302  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12303  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12304  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12306  duty2lab.config(text="Width mS")
12307  phaseblab.config(text = "Rise Time")
12308  UpdateAwgCont()
12309 #
12311  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12312  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12313  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12314  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12315  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12316  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12317 
12318  BAWGBAmpl(0)
12319  BAWGBOffset(0)
12320  BAWGBFreq(0)
12321  BAWGBPhase(0)
12322  BAWGBDutyCycle(0)
12323 
12324  if AWGBFreqvalue > 0.0:
12325  if AWG_2X.get() == 2:
12326  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12327  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12328  else:
12329  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12330  SamplesPermS = int(BaseSampleRate/1000) # 100
12331  else:
12332  AWGBperiodvalue = 0.0
12333  if AWG_Amp_Mode.get() == 1:
12334  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12335  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12336  else:
12337  MaxV = AWGBOffsetvalue
12338  MinV = AWGBAmplvalue
12339  AWGBwaveform = []
12340  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12341  if SlopeValue <= 0:
12342  SlopeValue = 1
12343  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12344  if PulseWidth <=0:
12345  PulseWidth = 1
12346  Remainder = int(AWGBperiodvalue - PulseWidth)
12347  if Remainder <= 0:
12348  Remainder = 1
12349  PulseWidth = PulseWidth - SlopeValue
12350  if PulseWidth <=0:
12351  PulseWidth = 1
12352  StepValue = (MaxV - MinV) / SlopeValue
12353  SampleValue = MinV
12354  for i in range(SlopeValue):
12355  AWGBwaveform.append(SampleValue)
12356  SampleValue = SampleValue + StepValue
12357  for i in range(PulseWidth):
12358  AWGBwaveform.append(MaxV)
12359  for i in range(Remainder):
12360  AWGBwaveform.append(MinV)
12361  if AWGBBurstFlag.get() == 1:
12362  TempOneCycle = AWGBwaveform
12363  for i in range(AWGBCycles-1):
12364  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12365  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12366  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12368  duty2lab.config(text="%")
12369  phaseblab.config(text = "Slope Time")
12370  UpdateAwgCont()
12371 #
12373  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12374  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12375  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12376  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12377  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12378  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12379 
12380  BAWGBAmpl(0)
12381  BAWGBOffset(0)
12382  BAWGBFreq(0)
12383  BAWGBPhase(0)
12384  BAWGBDutyCycle(0)
12385 
12386  if AWGBFreqvalue > 0.0:
12387  if AWG_2X.get() == 2:
12388  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12389  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12390  else:
12391  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12392  SamplesPermS = int(BaseSampleRate/1000) # 100
12393  else:
12394  AWGBperiodvalue = 0.0
12395  if AWG_Amp_Mode.get() == 1:
12396  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12397  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12398  else:
12399  MaxV = AWGBOffsetvalue
12400  MinV = AWGBAmplvalue
12401  #
12402  if AWGBPhaseDelay.get() == 0:
12403  if AWGBPhasevalue > 0:
12404  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12405  else:
12406  AWGBdelayvalue = 0.0
12407  elif AWGBPhaseDelay.get() == 1:
12408  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12409  #
12410  AWGBwaveform = []
12411  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12412  if PulseWidth <=0:
12413  PulseWidth = 1
12414  Remainder = int(AWGBperiodvalue - PulseWidth)
12415  if Remainder <= 0:
12416  Remainder = 1
12417  UpStepValue = (MaxV - MinV) / PulseWidth
12418  DownStepValue = (MaxV - MinV) / Remainder
12419  SampleValue = MinV
12420  for i in range(PulseWidth):
12421  AWGBwaveform.append(SampleValue)
12422  SampleValue = SampleValue + UpStepValue
12423  for i in range(Remainder):
12424  AWGBwaveform.append(SampleValue)
12425  SampleValue = SampleValue - DownStepValue
12426  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12427  if AWGBBurstFlag.get() == 1:
12428  TempOneCycle = AWGBwaveform
12429  for i in range(AWGBCycles-1):
12430  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12431  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12432  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12434  BAWGBPhaseDelay()
12435  duty2lab.config(text = "Symmetry")
12436  BAWGBPhaseDelay()
12437  UpdateAwgCont()
12438 #
12440  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12441  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12442  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12443  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12444  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12445  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12446 
12447  BAWGBAmpl(0)
12448  BAWGBOffset(0)
12449  BAWGBFreq(0)
12450  BAWGBPhase(0)
12451  BAWGBDutyCycle(0)
12452 
12453  if AWGBFreqvalue > 0.0:
12454  if AWG_2X.get() == 2:
12455  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12456  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12457  else:
12458  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12459  SamplesPermS = int(BaseSampleRate/1000) # 100
12460  else:
12461  AWGBperiodvalue = 0.0
12462  if AWG_Amp_Mode.get() == 1:
12463  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12464  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12465  else:
12466  MaxV = AWGBOffsetvalue
12467  MinV = AWGBAmplvalue
12468  AWGBwaveform = []
12469  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
12470  if AWGBPhaseDelay.get() == 0:
12471  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
12472  elif AWGBPhaseDelay.get() == 1:
12473  DelayValue = int(AWGBPhasevalue*SamplesPermS)
12474  for i in range(DelayValue-PulseWidth):
12475  AWGBwaveform.append((MinV+MaxV)/2)
12476  for i in range(PulseWidth):
12477  AWGBwaveform.append(MaxV)
12478  for i in range(PulseWidth):
12479  AWGBwaveform.append(MinV)
12480  DelayValue = int(AWGBperiodvalue-DelayValue)
12481  for i in range(DelayValue-PulseWidth):
12482  AWGBwaveform.append((MinV+MaxV)/2)
12483  if AWGBBurstFlag.get() == 1:
12484  TempOneCycle = AWGBwaveform
12485  for i in range(AWGBCycles-1):
12486  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12487  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12488  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12490  duty2lab.config(text = "Duty Cycle")
12491  BAWGBPhaseDelay()
12492  UpdateAwgCont()
12493 
12495  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12496  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12497  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12498  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12499  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12500 
12501  BAWGBAmpl(0)
12502  BAWGBOffset(0)
12503  BAWGBFreq(0)
12504 
12505  if AWGBFreqvalue > 0.0:
12506  if AWG_2X.get() == 2:
12507  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12508  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12509  else:
12510  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12511  SamplesPermS = int(BaseSampleRate/1000) # 100
12512  else:
12513  AWGBperiodvalue = 0.0
12514 
12515  if AWGBAmplvalue > AWGBOffsetvalue:
12516  MinV = AWGBOffsetvalue
12517  MaxV = AWGBAmplvalue
12518  else:
12519  MaxV = AWGBOffsetvalue
12520  MinV = AWGBAmplvalue
12521  if AWG_Amp_Mode.get() == 1:
12522  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12523  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12524  AWGBwaveform = []
12525  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
12526  Mid = (MaxV+MinV)/2
12527  if AWGBBurstFlag.get() == 1:
12528  TempOneCycle = AWGBwaveform
12529  for i in range(AWGBCycles-1):
12530  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12531  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12532  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12534  BAWGBPhaseDelay()
12535  UpdateAwgCont()
12536 
12538  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12539  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12540  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12541  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12542  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12543 
12544  BAWGBAmpl(0)
12545  BAWGBOffset(0)
12546  BAWGBFreq(0)
12547 
12548  if AWGBFreqvalue > 0.0:
12549  if AWG_2X.get() == 2:
12550  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12551  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12552  else:
12553  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12554  SamplesPermS = int(BaseSampleRate/1000) # 100
12555  else:
12556  AWGBperiodvalue = 0.0
12557  if AWGBAmplvalue > AWGBOffsetvalue:
12558  MinV = AWGBOffsetvalue
12559  MaxV = AWGBAmplvalue
12560  else:
12561  MaxV = AWGBOffsetvalue
12562  MinV = AWGBAmplvalue
12563  if AWG_Amp_Mode.get() == 1:
12564  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12565  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12566  AWGBwaveform = []
12567  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
12568  Mid = (MaxV+MinV)/2
12569  if AWGBBurstFlag.get() == 1:
12570  TempOneCycle = AWGBwaveform
12571  for i in range(AWGBCycles-1):
12572  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12573  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12574  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12576  BAWGBPhaseDelay()
12577  UpdateAwgCont()
12578 
12580  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
12581  global EnableScopeOnly
12582 
12583  if AWGBMode.get() == 0: # Source Voltage measure current mode
12584  label_txt = "SVMI"
12585  elif AWGBMode.get() == 1: # Source current measure voltage mode
12586  label_txt = "SIMV"
12587  elif AWGBMode.get() == 2: # High impedance mode
12588  label_txt = "Hi-Z"
12589  if AWGBIOMode.get() > 0: # Split Input / Output mode
12590  if HWRevOne == "D":
12591  if AWGBMode.get() == 0:
12592  AWGBMode.set(1)
12593  CHB.set_mode('i') # channel must be in source current mode for rev D boards
12594  label_txt = "SIMV"
12595  label_txt = label_txt + " Split I/O"
12596  if EnableScopeOnly == 0:
12597  label_txt = label_txt + " Mode"
12598  AWGBModeLabel.config(text = label_txt ) # change displayed value
12599  ReMakeAWGwaves()
12600  #UpdateAwgCont()
12601 
12603  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
12604  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
12605  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
12606  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
12607  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
12608  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12609  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag, EnableScopeOnly
12610  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12611 
12612  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
12613  amp2lab.config(text = "Min Ch B" ) # change displayed value
12614  off2lab.config(text = "Max Ch B" ) # change displayed value
12615  else:
12616  amp2lab.config(text = "Amp Ch B" )
12617  off2lab.config(text = "Off Ch B" )
12618 #
12619  if AWG_2X.get() == 1:
12620  AWGBWave = 'arbitrary'
12621  if AWGBFreqvalue > 0.0:
12622  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
12623  else:
12624  AWGBperiodvalue = 0.0
12625 #
12626  if AWGBPhaseDelay.get() == 0:
12627  if AWGBWave == 'square':
12628  AWGBPhasevalue = AWGBPhasevalue + 270.0
12629  if AWGBPhasevalue > 359:
12630  AWGBPhasevalue = AWGBPhasevalue - 360
12631  if AWGBPhasevalue > 0:
12632  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12633  else:
12634  AWGBdelayvalue = 0.0
12635  elif AWGBPhaseDelay.get() == 1:
12636  AWGBdelayvalue = AWGBPhasevalue * 100
12637 #
12638  if AWGBTerm.get() == 0: # Open termination
12639  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12640  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12641  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
12642  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12643  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
12644  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
12645  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
12646  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12647 
12648  if AWGBWave == 'dc':
12649  if AWG_2X.get() == 1:
12650  AWGBWave == 'arbitrary'
12651  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12652  else:
12653  if AWGBMode.get() == 0: # Source Voltage measure current mode
12654  if AWGBIOMode.get() == 0:
12655  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12656  else:
12657  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12658  CHB.constant(AWGBOffsetvalue)
12659  if AWGBMode.get() == 1: # Source current measure Voltage mode
12660  if AWGBIOMode.get() == 0:
12661  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12662  else:
12663  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12664  CHB.constant(AWGBOffsetvalue/1000)
12665  if AWGBMode.get() == 2: # Hi impedance mode
12666  if AWGBIOMode.get() == 0:
12667  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12668  else:
12669  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12670 #
12671  if AWGBIOMode.get() > 0: # Split Input / Output mode
12672  if HWRevOne == "D":
12673  AWGBMode.set(1)
12674  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12675 #
12676  else:
12677  if AWGBMode.get() == 0: # Source Voltage measure current mode
12678  if AWGBIOMode.get() == 0:
12679  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12680  else:
12681  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12682  if AWGBMode.get() == 1: # Source current measure Voltage mode
12683  if AWGBIOMode.get() == 0:
12684  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12685  else:
12686  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12687  AWGBOffsetvalue = AWGBOffsetvalue/1000
12688  AWGBAmplvalue = AWGBAmplvalue/1000
12689  if AWGBMode.get() == 2: # Hi impedance mode
12690  if AWGBIOMode.get() == 0:
12691  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12692  else:
12693  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12694  else:
12695  if AWG_Amp_Mode.get() == 1:
12696  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12697  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12698  else:
12699  MaxV = AWGBOffsetvalue
12700  MinV = AWGBAmplvalue
12701  try: # keep going even if low level library returns an error
12702  if AWGBWave == 'sine':
12703  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12704  elif AWGBWave == 'triangle':
12705  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12706  elif AWGBWave == 'sawtooth':
12707  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12708  elif AWGBWave == 'square':
12709  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
12710  elif AWGBWave == 'stairstep':
12711  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12712  elif AWGBWave == 'arbitrary':
12713  if EnableScopeOnly == 0:
12714  AddAWGBNoise()
12715  if AWGSync.get() == 0:
12716  AWGBRepeatFlag.set(1)
12717  if AWG_2X.get() == 1:
12718  AWGBWave == 'arbitrary'
12719  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12720  else:
12721  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
12722  except:
12723  donothing()
12724  if AWGBIOMode.get() > 0: # Split Input / Output mode
12725  if HWRevOne == "D":
12726  AWGBMode.set(1)
12727  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12728 #
12730  global AWG_2X, AWGA2X, AWGBwaveform
12731  global AWGBNoiseEntry, AWGBsbnoise, AWGBNoisevalue
12732 
12733  if AWGBsbnoise.get() == "None":
12734  return
12735  else:
12736  try:
12737  AWGBNoisevalue = float(eval(AWGBNoiseEntry.get()))
12738  except:
12739  AWGBNoiseEntry.delete(0,"end")
12740  AWGBNoiseEntry.insert(0, AWGBNoisevalue)
12741  if AWGBNoisevalue == 0.0:
12742  return
12743  AWGBNoiseform = []
12744  if AWGBsbnoise.get() == "Gaussian":
12745  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGBwaveform))
12746  else:
12747  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGBwaveform))
12748  AWGBwaveform = AWGBwaveform + AWGBNoiseform
12749  if AWG_2X.get() == 2:
12750  if AWGBsbnoise.get() == "Gaussian":
12751  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGA2X))
12752  else:
12753  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGA2X))
12754  AWGA2X = AWGA2X + AWGBNoiseform
12755 #
12757  global session, CHA, CHB, AWGSync
12758  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
12759  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
12760  if session.continuous:
12761  session.end()
12762  BAWGEnab() # set-up new AWG settings
12763  time.sleep(0.01) # wait awhile here for some reason
12764  session.start(0)
12765 #
12767  ReMakeAWGwaves()
12768 
12769 def BAWGEnab():
12770  global AWGAMode, AWGBMode, AWGSync
12771  global CHA, CHB, discontloop, contloop, session
12772 
12773  # Stream = False
12774  # print "Updateing AWGs"
12775  BAWGAAmpl(0)
12776  BAWGAOffset(0)
12777  BAWGAFreq(0)
12778  BAWGAPhase(0)
12779  BAWGADutyCycle(0)
12780  BAWGAShape()
12781  BAWGBAmpl(0)
12782  BAWGBOffset(0)
12783  BAWGBFreq(0)
12784  BAWGBPhase(0)
12785  BAWGBDutyCycle(0)
12786  BAWGBShape()
12787  UpdateAWGA()
12788  UpdateAWGB()
12789 
12790 def BAWGSync():
12791  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
12792 
12793  if (RUNstatus.get() == 1): # do this only if running
12794  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
12795  AWGSync.set(1)
12796  return
12797  if AWGSync.get() == 0:
12798  #UpdateAwgCont()
12799  session.flush()
12800  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12801  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12802  BAWGEnab()
12803  session.start(0)
12804  time.sleep(0.02) # wait awhile here for some reason
12805  elif session.continuous:
12806  session.end()
12807  session.flush()
12808  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12809  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12810 
12811 # ======= Spectrum Analyzer functions ===========
12812 #
12814  global CANVASwidthF, CANVASheightF, freqwindow
12815  global COLORtext
12816  # ask for file name
12817  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
12818  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
12819  if MarkerNum > 0 or ColorMode.get() > 0:
12820  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12821  else: # temp change text color to black
12822  COLORtext = "#000000"
12824  # save postscript file
12825  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12826  #
12827  COLORtext = "#ffffff"
12829 #
12830 def Bnot():
12831  print( "Routine not made yet")
12832 
12834  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12835  ShowC1_VdB.set(1)
12836  ShowC1_P.set(1)
12837  ShowC2_VdB.set(1)
12838  ShowC2_P.set(1)
12839 
12841  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12842  ShowC1_VdB.set(0)
12843  ShowC1_P.set(0)
12844  ShowC2_VdB.set(0)
12845  ShowC2_P.set(0)
12846 
12848  global RUNstatus
12849  global FreqTraceMode
12850 
12851  FreqTraceMode.set(1)
12852  if RUNstatus.get() == 0: # Update if stopped
12854  if RUNstatus.get() == 2: # Restart if running
12855  RUNstatus.set(4)
12856 
12858  global RUNstatus
12859  global FreqTraceMode
12860 
12861  FreqTraceMode.set(2)
12862  if RUNstatus.get() == 0: # Update if stopped
12864  if RUNstatus.get() == 2: # Restart if running
12865  RUNstatus.set(4)
12866 
12868  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
12869 
12870  FreqTraceMode.set(3)
12871 
12872  if RUNstatus.get() == 0: # Update if stopped
12874  if RUNstatus.get() == 2: # Restart if running
12875  RUNstatus.set(4)
12876 
12878  global FreqTraceMode, TRACEresetFreq
12879 
12880  if FreqTraceMode.get()==3:
12881  TRACEresetFreq = True
12882 
12884  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
12885  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
12886  global T1Pline, T2Pline, T1PRline, T2PRline
12887  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12888  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12889  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12890  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12891  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12892 
12893  if ShowC1_VdB.get() == 1:
12894  T1FRline = T1Fline
12895  PeakxRA = PeakxA
12896  PeakyRA = PeakyA
12897  PeakdbRA = PeakdbA
12898  PeakfreqRA = PeakfreqA
12899  if ShowC2_VdB.get() == 1:
12900  T2FRline = T2Fline
12901  PeakxRB = PeakxB
12902  PeakyRB = PeakyB
12903  PeakdbRB = PeakdbB
12904  PeakfreqRB = PeakfreqB
12905  if ShowC1_P.get() == 1:
12906  T1PRline = T1Pline
12907  if ShowC2_P.get() == 1:
12908  T2PRline = T2Pline
12909  if ShowMathSA.get() > 0:
12910  TFRMline = TFMline
12911  PeakxRM = PeakxM
12912  PeakyRM = PeakyM
12913  PeakRMdb = PeakMdb
12914  PeakfreqRM = PeakfreqM
12915 
12916  UpdateFreqTrace() # Always Update
12917 #
12919  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
12920  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
12921  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
12922  global TAPline, TBPline, TAPRline, TBPRline
12923  global TIARline, TIAXline, TIAMagline, TIAAngline
12924  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12925  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12926  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12927  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12928  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12929  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12930 
12931  if ShowCA_VdB.get() == 1:
12932  TAFRline = TAFline
12933  PeakxRA = PeakxA
12934  PeakyRA = PeakyA
12935  PeakdbRA = PeakdbA
12936  PeakfreqRA = PeakfreqA
12937  if ShowCB_VdB.get() == 1:
12938  TBFRline = TBFline
12939  PeakxRB = PeakxB
12940  PeakyRB = PeakyB
12941  PeakdbRB = PeakdbB
12942  PeakfreqRB = PeakfreqB
12943  if ShowCA_P.get() == 1:
12944  TAPRline = TAPline
12945  if ShowCB_P.get() == 1:
12946  TBPRline = TBPline
12947  if ShowMathBP.get() > 0:
12948  TBPRMline = TBPMline
12949  PeakxRM = PeakxM
12950  PeakyRM = PeakyM
12951  PeakRMdb = PeakMdb
12952  PeakfreqRM = PeakfreqM
12953  if Show_Rseries.get() > 0:
12954  RefIARline = TIARline
12955  if Show_Xseries.get() > 0:
12956  RefIAXline = TIAXline
12957  if Show_Magnitude.get() > 0:
12958  RefIAMagline = TIAMagline
12959  if Show_Angle.get() > 0:
12960  RefIAAngline = TIAAngline
12961  UpdateBodeTrace() # Always Update
12962 #
12963 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
12964  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
12965  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, TRACEsize
12966 
12967  # Set the TRACEsize variable
12968  if ShowCA_VdB.get() == 1:
12969  TRACEsize = len(FSweepAdB) # Set the trace length
12970  elif ShowCA_VdB.get() == 1:
12971  TRACEsize = len(FSweepBdB)
12972  if TRACEsize == 0: # If no trace, skip rest of this routine
12973  return()
12974 # ask if save as magnitude or dB
12975  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
12976 # Yes 1 = dB, No 0 = Mag
12977  # Make the file name and open it
12978  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
12979  filename = "Bode-" + tme
12980  filename = filename + ".csv"
12981  # open file to save data
12982  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
12983  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
12984  DataFile = open(filename,'a') # Open output file
12985  HeaderString = 'Frequency-#, '
12986  if ShowCA_VdB.get() == 1:
12987  if dB == 1:
12988  HeaderString = HeaderString + 'CA-dB, '
12989  if dB == 0:
12990  HeaderString = HeaderString + 'CA-Mag, '
12991  if ShowCB_VdB.get() == 1:
12992  if dB == 1:
12993  HeaderString = HeaderString + 'CB-dB, '
12994  if dB == 0:
12995  HeaderString = HeaderString + 'CB-Mag, '
12996  if ShowCA_P.get() == 1:
12997  HeaderString = HeaderString + 'Phase A-B, '
12998  if ShowCB_P.get() == 1:
12999  HeaderString = HeaderString + 'Phase B-A, '
13000  HeaderString = HeaderString + '\n'
13001  DataFile.write( HeaderString )
13002 
13003  n = 0
13004  while n < len(FSweepAdB):
13005  F = FBins[FStep[n]] # look up frequency bin in list of bins
13006  txt = str(F)
13007  if ShowCA_VdB.get() == 1:
13008  V = 10 * math.log10(float(FSweepAdB[n]))
13009  if dB == 0:
13010  V = 10.0**(V/20.0)
13011  txt = txt + "," + str(V)
13012  if ShowCB_VdB.get() == 1:
13013  V = 10 * math.log10(float(FSweepBdB[n]))
13014  if dB == 0:
13015  V = 10.0**(V/20.0)
13016  txt = txt + "," + str(V)
13017  if ShowCA_P.get() == 1:
13018  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
13019  if RelPhase > 180:
13020  RelPhase = RelPhase - 360
13021  elif RelPhase < -180:
13022  RelPhase = RelPhase + 360
13023  txt = txt + "," + str(RelPhase)
13024  if ShowCB_P.get() == 1:
13025  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
13026  if RelPhase > 180:
13027  RelPhase = RelPhase - 360
13028  elif RelPhase < -180:
13029  RelPhase = RelPhase + 360
13030  txt = txt + "," + str(RelPhase)
13031  txt = txt + "\n"
13032  DataFile.write(txt)
13033  n = n + 1
13034 
13035  DataFile.close() # Close the file
13036 
13038  global iawindow, FStep, FBins
13039  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13040 
13041  if NetworkScreenStatus.get() > 0:
13042  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
13043  filename = "Impedance-" + tme
13044  filename = filename + ".csv"
13045  # open file to save data
13046  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
13047  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
13048  DataFile = open(filename,'a') # Open output file
13049  HeaderString = 'Frequency, Series R, Series X, Series Z, Series Angle'
13050  HeaderString = HeaderString + '\n'
13051  DataFile.write( HeaderString )
13052 
13053  n = 0
13054  while n < len(NSweepSeriesR):
13055  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
13056  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
13057  txt = txt + "\n"
13058  DataFile.write(txt)
13059  n = n + 1
13060  DataFile.close() # Close the file
13061  else:
13062  return
13063 #
13064 def BStartSA():
13065  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
13066  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
13067  global Two_X_Sample, ADC_Mux_Mode, ShowAWGASA, ShowAWGBSA
13068 
13069  #AWGSync.set(0) # always run in continuous mode
13070  if DevID == "No Device":
13071  showwarning("WARNING","No Device Plugged In!")
13072  elif FWRevOne == 0.0:
13073  showwarning("WARNING","Out of data Firmware!")
13074  else:
13075  if PowerStatus == 0:
13076  PowerStatus = 1
13077  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13078  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13079 
13080  if (ShowC1_VdB.get() == 0 and
13081  ShowC2_VdB.get() == 0 and
13082  ShowMathSA.get() == 0 and
13083  ShowAWGASA.get() == 0 and
13084  ShowAWGBSA.get() == 0 and
13085  ShowC1_P.get() == 0 and
13086  ShowC2_P.get() == 0):
13087  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
13088  return()
13089  try:
13090  StopFrequency = float(StopFreqEntry.get())
13091  except:
13092  StopFreqEntry.delete(0,"end")
13093  StopFreqEntry.insert(0,50000)
13094  StopFrequency = 50000
13095  if FWRevOne > 2.16:
13096  if StopFrequency >= 50000:
13097  Two_X_Sample.set(1)
13098  else:
13099  Two_X_Sample.set(0)
13100  ADC_Mux_Mode.set(0)
13101  SetADC_Mux()
13102  #
13103  BStart()
13104 #
13105  UpdateFreqAll() # Always Update
13106 
13107 def BStopSA():
13108  global RUNstatus, session, AWGSync
13109 
13110  if (RUNstatus.get() == 1):
13111  RUNstatus.set(0)
13112  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
13113  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13114  if AWGSync.get() == 0: # running in continuous mode
13115  CHA.constant(0.0)
13116  CHB.constant(0.0)
13117  # print "Stoping continuous mode"
13118  if session.continuous:
13119  # print "Stoping Is Continuous? ", session.continuous
13120  time.sleep(0.02)
13121  #print "Is Continuous? ", session.continuous
13122  else:
13123  contloop = 0
13124  discontloop = 1
13125  session.cancel()
13126  elif (RUNstatus.get() == 2):
13127  RUNstatus.set(3)
13128  elif (RUNstatus.get() == 3):
13129  RUNstatus.set(3)
13130  elif (RUNstatus.get() == 4):
13131  RUNstatus.set(3)
13132  UpdateFreqAll() # Always Update
13133 
13134 def Blevel1():
13135  global DBlevel
13136  global RUNstatus
13137 
13138  DBlevel.set(DBlevel.get() - 1)
13139 
13140  if RUNstatus.get() == 0: # Update if stopped
13141  UpdateFreqTrace()
13142 
13143 def Blevel2():
13144  global DBlevel
13145  global RUNstatus
13146 
13147  DBlevel.set(DBlevel.get() + 1)
13148 
13149  if RUNstatus.get() == 0: # Update if stopped
13150  UpdateFreqTrace()
13151 
13152 def Blevel3():
13153  global DBlevel
13154  global RUNstatus
13155 
13156  DBlevel.set(DBlevel.get() - 10)
13157 
13158  if RUNstatus.get() == 0: # Update if stopped
13159  UpdateFreqTrace()
13160 
13161 def Blevel4():
13162  global DBlevel
13163  global RUNstatus
13164 
13165  DBlevel.set(DBlevel.get() + 10)
13166 
13167  if RUNstatus.get() == 0: # Update if stopped
13168  UpdateFreqTrace()
13169 #
13171  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
13172  global SMPfftpwrTwo, SMPfft, FFTwindow
13173  global TRACEresetFreq, PhAScreenStatus
13174 
13175  if FFTwindow.get() != 8:
13176  if (SMPfftpwrTwo.get() > 6): # Min 64
13177  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
13178  TRACEresetFreq = True # Reset trace peak and trace average
13179  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13180 
13181  if RUNstatus.get() == 0: # Update if stopped
13182  if SpectrumScreenStatus.get() > 0:
13184  if IAScreenStatus.get() > 0:
13185  UpdateIAScreen()
13186  if PhAScreenStatus.get() > 0:
13187  UpdatePhAScreen()
13188  if RUNstatus.get() == 2: # Restart if running
13189  RUNstatus.set(4)
13190 
13192  global RUNstatus, PhAScreenStatus
13193  global SMPfftpwrTwo, SMPfft, FFTwindow
13194  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
13195 
13196  if FFTwindow.get() != 8:
13197  if (SMPfftpwrTwo.get() < 16): # Max 65536
13198  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
13199  TRACEresetFREQ = True # Reset trace peak and trace average
13200  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13201 
13202  if RUNstatus.get() == 0: # Update if stopped
13203  if SpectrumScreenStatus.get() > 0:
13205  if IAScreenStatus.get() > 0:
13206  UpdateIAScreen()
13207  if PhAScreenStatus.get() > 0:
13208  UpdatePhAScreen()
13209  if RUNstatus.get() == 2: # Restart if running
13210  RUNstatus.set(4)
13211 
13212 def BDBdiv1():
13213  global DBdivindex
13214  global RUNstatus
13215 
13216  if (DBdivindex.get() >= 1):
13217  DBdivindex.set(DBdivindex.get() - 1)
13218 
13219  if RUNstatus.get() == 0: # Update if stopped
13220  UpdateFreqTrace()
13221 
13222 def BDBdiv2():
13223  global DBdivindex
13224  global DBdivlist
13225  global RUNstatus
13226 
13227  if (DBdivindex.get() < len(DBdivlist) - 1):
13228  DBdivindex.set(DBdivindex.get() + 1)
13229 
13230  if RUNstatus.get() == 0: # Update if stopped
13231  UpdateFreqTrace()
13232 #----- Bode Plot controls
13233 def BStartBP():
13234  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
13235  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
13236  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
13237  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
13238  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
13239  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
13240  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
13241  global BeginIndex, EndIndex
13242 
13243  if DevID == "No Device":
13244  showwarning("WARNING","No Device Plugged In!")
13245  elif FWRevOne == 0.0:
13246  showwarning("WARNING","Out of data Firmware!")
13247  else:
13248  if PowerStatus == 0:
13249  PowerStatus = 1
13250  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13251  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13252 
13253  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
13254  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
13255  return()
13256  #
13257  if ZEROstuffing.get() < 3:
13258  ZEROstuffing.set(3)
13259  CutDC.set(1) # set to remove DC
13260  try:
13261  EndFreq = float(StopBodeEntry.get())
13262  except:
13263  StopBodeEntry.delete(0,"end")
13264  StopBodeEntry.insert(0,10000)
13265  EndFreq = 10000
13266  if FWRevOne > 2.16:
13267  if EndFreq >= 20000:
13268  Two_X_Sample.set(1)
13269  FBins = numpy.linspace(0, 100000, num=32768) #16384)
13270  else:
13271  Two_X_Sample.set(0)
13272  FBins = numpy.linspace(0, 50000, num=32768) #16384)
13273  ADC_Mux_Mode.set(0)
13274  SetADC_Mux()
13275  try:
13276  BeginFreq = float(StartBodeEntry.get())
13277  except:
13278  StartBodeEntry.delete(0,"end")
13279  StartBodeEntry.insert(0,100)
13280  BeginFreq = 100
13281  #
13282  if FSweepMode.get() == 1:
13283  if AWGAMode.get() == 2:
13284  AWGAMode.set(0) # Set AWG A to SVMI
13285  AWGAShape.set(18) # Set Shape to Sine
13286  if Two_X_Sample.get() == 1:
13287  AWGBIOMode.set(1)
13288  AWGBMode.set(0)
13289  else:
13290  AWGBMode.set(2) # Set AWG B to Hi-Z
13291  AWG_2X.set(0)
13292  BAWG2X()
13293  Reset_Freq = AWGAFreqEntry.get()
13294  if FSweepMode.get() == 2:
13295  if AWGBMode.get() == 2:
13296  AWGBMode.set(0) # Set AWG B to SVMI
13297  AWGBShape.set(18) # Set Shape to Sine
13298  if Two_X_Sample.get() == 1:
13299  AWGAIOMode.set(1)
13300  AWGAMode.set(0)
13301  else:
13302  AWGAMode.set(2) # Set AWG A to Hi-Z
13303  AWG_2X.set(0)
13304  BAWG2X()
13305  Reset_Freq = AWGBFreqEntry.get()
13306  if FSweepMode.get() == 3: # using external Minigen
13307  AWGAMode.set(2) # Set AWG A to Hi-Z
13308  AWGBMode.set(2) # Set AWG B to Hi-Z
13309  try:
13310  NSteps.set(float(SweepStepBodeEntry.get()))
13311  except:
13312  SweepStepBodeEntry.delete(0,"end")
13313  SweepStepBodeEntry.insert(0, NSteps.get())
13314  #
13315  if FSweepMode.get() > 0:
13316  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
13317  BAWGBModeLabel()
13318  LoopNum.set(1)
13319  NyquistFreq = SAMPLErate/2
13320  BeginIndex = int((BeginFreq/NyquistFreq)*32768)#16384)
13321  EndIndex = int((EndFreq/NyquistFreq)*32768)#16384)
13322  if NSteps.get() < 5:
13323  NSteps.set(5)
13324  if HScaleBP.get() == 1:
13325  LogFStop = math.log10(EndIndex)
13326  try:
13327  LogFStart = math.log10(BeginIndex)
13328  except:
13329  LogFStart = 0.1
13330  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
13331  else:
13332  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
13333 
13334  BStart()
13335  # UpdateBodeAll() # Always Update
13336 #
13337 def BStopBP():
13338  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
13339 
13340  if FSweepMode.get() == 1:
13341  AWGAFreqEntry.delete(0,"end")
13342  AWGAFreqEntry.insert(0, Reset_Freq)
13343  if FSweepMode.get() == 2:
13344  AWGBFreqEntry.delete(0,"end")
13345  AWGBFreqEntry.insert(0, Reset_Freq)
13346 #
13347  if (RUNstatus.get() == 1):
13348  RUNstatus.set(0)
13349  if AWGSync.get() == 0: # running in continuous mode
13350  session.cancel() # cancel continuous session mode while paused
13351  elif (RUNstatus.get() == 2):
13352  RUNstatus.set(3)
13353  elif (RUNstatus.get() == 3):
13354  RUNstatus.set(3)
13355  elif (RUNstatus.get() == 4):
13356  RUNstatus.set(3)
13357  UpdateBodeAll() # Always Update
13358 #
13360  global DBlevelBP
13361  global RUNstatus
13362 
13363  DBlevelBP.set(DBlevelBP.get() - 1)
13364 
13365  if RUNstatus.get() == 0: # Update if stopped
13366  UpdateBodeTrace()
13367 
13369  global DBlevelBP
13370  global RUNstatus
13371 
13372  DBlevelBP.set(DBlevelBP.get() + 1)
13373 
13374  if RUNstatus.get() == 0: # Update if stopped
13375  UpdateBodeTrace()
13376 
13378  global DBlevelBP
13379  global RUNstatus
13380 
13381  DBlevelBP.set(DBlevelBP.get() - 10)
13382 
13383  if RUNstatus.get() == 0: # Update if stopped
13384  UpdateBodeTrace()
13385 
13387  global DBlevelBP
13388  global RUNstatus
13389 
13390  DBlevelBP.set(DBlevelBP.get() + 10)
13391 
13392  if RUNstatus.get() == 0: # Update if stopped
13393  UpdateBodeTrace()
13394 
13396  global DBdivindexBP
13397  global RUNstatus
13398 
13399  if (DBdivindexBP.get() >= 1):
13400  DBdivindexBP.set(DBdivindexBP.get() - 1)
13401 
13402  if RUNstatus.get() == 0: # Update if stopped
13403  UpdateBodeTrace()
13404 
13406  global DBdivindexBP
13407  global DBdivlist
13408  global RUNstatus
13409 
13410  if (DBdivindexBP.get() < len(DBdivlist) - 1):
13411  DBdivindexBP.set(DBdivindexBP.get() + 1)
13412 
13413  if RUNstatus.get() == 0: # Update if stopped
13414  UpdateBodeTrace()
13415 #
13417  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13418  ShowCA_VdB.set(1)
13419  ShowCA_P.set(1)
13420  ShowCB_VdB.set(1)
13421  ShowCB_P.set(1)
13422 
13424  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13425  ShowCA_VdB.set(0)
13426  ShowCA_P.set(0)
13427  ShowCB_VdB.set(0)
13428  ShowCB_P.set(0)
13429 # Bode Plot refresh
13430 def UpdateBodeAll(): # Update Data, trace and screen
13431  global FFTBuffA, FFTBuffB
13432  global SMPfft
13433 
13434  # DoFFT() # Fast Fourier transformation
13435  MakeBodeTrace() # Update the traces
13436  UpdateBodeScreen() # Update the screen
13437 
13438 def UpdateBodeTrace(): # Update trace and screen
13439  MakeBodeTrace() # Update traces
13440  UpdateBodeScreen() # Update the screen
13441 
13442 def UpdateBodeScreen(): # Update screen with trace and text
13443  MakeBodeScreen() # Update the screen
13444 
13445 # ============================================ Freq Main routine ====================================================
13446 
13447 def UpdateFreqAll(): # Update Data, trace and screen
13448  global FFTBuffA, FFTBuffB
13449  global SMPfft
13450 
13451  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13452  return
13453 
13454  # DoFFT() # Fast Fourier transformation
13455  MakeFreqTrace() # Update the traces
13456  UpdateFreqScreen() # Update the screen
13457 
13458 def UpdateFreqTrace(): # Update trace and screen
13459  MakeFreqTrace() # Update traces
13460  UpdateFreqScreen() # Update the screen
13461 
13462 def UpdateFreqScreen(): # Update screen with trace and text
13463  MakeFreqScreen() # Update the screen
13464 
13465 def DoFFT(): # Fast Fourier transformation
13466  global FFTBuffA, FFTBuffB, AWGAwaveform, AWGBwaveform
13467  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowAWGASA, ShowAWGBSA
13468  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
13469  global FFTmemoryB, FFTresultB, FFTresultAWGA, FFTresultAWGB
13470  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
13471  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13472  global FFTwindowshape, FFTbandwidth
13473  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
13474  global SMPfft, LoopNum, IA_Ext_Conf
13475  global STARTsample, STOPsample, CutDC
13476  global TRACEaverage, FreqTraceMode, FSweepMode
13477  global TRACEresetFreq, ZEROstuffing
13478  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
13479  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13480  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesL
13481 
13482  # T1 = time.time() # For time measurement of FFT routine
13483  REX = []
13484  PhaseA = []
13485  PhaseB = []
13486  # Convert list to numpy array REX for faster Numpy calculations
13487  # Take the first fft samples
13488  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
13489 
13490  # Set Analog level display value MAX value is 5 volts for ALM1000
13491  REX = REX / 5.0
13492 
13493  # Do the FFT window function
13494  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
13495 
13496  # Zero stuffing of array for better interpolation of peak level of signals
13497  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13498  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13499 
13500  # Save previous trace in memory for max or average trace
13501  FFTmemoryA = FFTresultA
13502  if FreqTraceMode.get() == 3:
13503  PhaseMemoryA = PhaseA
13504 
13505  # FFT with numpy
13506  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13507  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
13508  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13509  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
13510 
13511  le = int(len(ALL) / 2) # Only half is used, other half is mirror
13512  # ALL = ALL[0:le] # So take only first half of the array
13513  FFTresultA = ALL[0:le]
13514  PhaseA = PhaseA[0:le]
13515  RMScorr = 1.0 / SMPfft # For VOLTAGE!
13516  Powcorr = 50*(RMScorr **2) # vpktage squared For POWER!
13517  FFTresultA = FFTresultA * Powcorr
13518 #
13519  REX = []
13520  # Convert list to numpy array REX for faster Numpy calculations
13521  # Take the first fft samples
13522  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
13523 
13524  # Set level display value MAX value is 5 volts for ALM1000
13525  REX = REX / 5.0
13526 
13527  # Do the FFT window function
13528  try:
13529  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13530  except:
13531  return
13532  # Zero stuffing of array for better interpolation of peak level of signals
13533  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13534  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13535 
13536  # Save previous trace in memory for max or average trace
13537  FFTmemoryB = FFTresultB
13538  if FreqTraceMode.get() == 3:
13539  PhaseMemoryB = PhaseB
13540  # FFT with numpy
13541  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13542  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13543  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13544  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13545 
13546  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13547  # ALL = ALL[0:le] # So take only first half of the array
13548  FFTresultB = ALL[0:le]
13549  PhaseB = PhaseB[0:le]
13550  FFTresultB = FFTresultB * Powcorr
13551 #
13552  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
13553  REX = []
13554  PhaseAB = []
13555  # Convert list to numpy array REX for faster Numpy calculations
13556  # Take the first fft samples
13557  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
13558 
13559  # Set level display value MAX value is 5 volts for ALM1000
13560  REX = REX / 5.0
13561 
13562  # Do the FFT window function
13563  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13564 
13565  # Zero stuffing of array for better interpolation of peak level of signals
13566  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13567  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13568 
13569  # Save previous trace in memory for max or average trace
13570  # FFTmemoryB = FFTresultB
13571  # if FreqTraceMode.get() == 3:
13572  # PhaseMemoryB = PhaseB
13573  # FFT with numpy
13574  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13575  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
13576  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13577  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13578 
13579  le = len(ALL) / 2 # Only half is used, other half is mirror
13580  #ALL = ALL[:le] # So take only first half of the array
13581  FFTresultAB = ALL[:le]
13582  PhaseAB = PhaseAB[:le]
13583  FFTresultAB = FFTresultAB * Powcorr
13584 #
13585  if ShowAWGASA.get() > 0:
13586  FFTAWGA = AWGAwaveform
13587  DCA = 0.0
13588  if CutDC.get() == 1:
13589  DCA = numpy.average(FFTAWGA)
13590  FFTAWGA = FFTAWGA - DCA
13591  if len(AWGAwaveform) < SMPfft:
13592  Repeats = math.ceil(SMPfft/len(AWGAwaveform))
13593  i = 0
13594  while i < Repeats:
13595  FFTAWGA = numpy.concatenate((FFTAWGA, AWGAwaveform-DCA))
13596  i = i + 1
13597  REX = []
13598  # Convert list to numpy array REX for faster Numpy calculations
13599  # Take the first fft samples
13600  REX = numpy.array(FFTAWGA[0:SMPfft]) # Make a numpy arry of the list
13601 
13602  # Set level display value MAX value is 5 volts for ALM1000
13603  REX = REX / 5.0
13604 
13605  # Do the FFT window function
13606  try:
13607  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13608  except:
13609  return
13610  # Zero stuffing of array for better interpolation of peak level of signals
13611  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13612  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13613  # FFT with numpy
13614  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13615  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13616  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13617  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13618 
13619  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13620  # ALL = ALL[0:le] # So take only first half of the array
13621  FFTresultAWGA = ALL[0:le]
13622  #PhaseB = PhaseB[0:le]
13623  FFTresultAWGA = FFTresultAWGA * Powcorr
13624 #
13625  if ShowAWGBSA.get() > 0:
13626  FFTAWGB = AWGBwaveform
13627  DCB = 0.0
13628  if CutDC.get() == 1:
13629  DCB = numpy.average(FFTAWGB)
13630  FFTAWGB = FFTAWGB - DCB
13631  if len(AWGBwaveform) < SMPfft:
13632  Repeats = math.ceil(SMPfft/len(AWGBwaveform))
13633  i = 1
13634  while i < Repeats:
13635  FFTAWGB = numpy.concatenate((FFTAWGB, AWGBwaveform-DCB))
13636  i = i + 1
13637  REX = []
13638  # Convert list to numpy array REX for faster Numpy calculations
13639  # Take the first fft samples
13640  REX = numpy.array(FFTAWGB[0:SMPfft]) # Make a numpy arry of the list
13641 
13642  # Set level display value MAX value is 5 volts for ALM1000
13643  REX = REX / 5.0
13644 
13645  # Do the FFT window function
13646  try:
13647  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13648  except:
13649  return
13650  # Zero stuffing of array for better interpolation of peak level of signals
13651  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13652  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13653  # FFT with numpy
13654  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13655  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13656  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13657  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13658 
13659  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13660  #ALL = ALL[0:le] # So take only first half of the array
13661  FFTresultAWGB = ALL[0:le]
13662  #PhaseB = PhaseB[0:le]
13663  FFTresultAWGB = FFTresultAWGB * Powcorr
13664 #
13665  TRACEsize = int(len(FFTresultB))
13666  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
13667  if SpectrumScreenStatus.get() > 0:
13668  try:
13669  StartFrequency = float(StartFreqEntry.get())
13670  except:
13671  StartFreqEntry.delete(0,"end")
13672  StartFreqEntry.insert(0,100)
13673  StartFrequency = 100
13674  STARTsample = int(StartFrequency / Fsample)
13675  else:
13676  STARTsample = 0
13677  if LoopNum.get() == 1:
13678  PhaseMemoryB = PhaseB
13679  FSweepAdB = []
13680  FSweepBdB = []
13681  FSweepAPh = []
13682  FSweepBPh = []
13683  if NetworkScreenStatus.get() > 0:
13684  NSweepSeriesR = []
13685  NSweepSeriesX = []
13686  NSweepSeriesMag = [] # in ohms
13687  NSweepSeriesAng = [] # in degrees
13688  NSweepParallelR = []
13689  NSweepParallelC = []
13690  NSweepParallelL = []
13691  NSweepSeriesC = []
13692  NSweepSeriesL = []
13693  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13694  if FSweepMode.get() == 1:
13695  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13696  if ptmax > STARTsample:
13697  STARTsample = ptmax
13698  i = 0
13699  while i < 6:
13700  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13701  i = i + 1
13702  if FSweepMode.get() == 2:
13703  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13704  if ptmax > STARTsample:
13705  STARTsample = ptmax
13706  i = 0
13707  while i < 6:
13708  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13709  i = i + 1
13710 
13711  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13712  if FSweepMode.get() == 1:
13713  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13714  if ptmax > STARTsample:
13715  STARTsample = ptmax
13716  i = 0
13717  while i < 6:
13718  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13719  i = i + 1
13720  if FSweepMode.get() == 2:
13721  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13722  if ptmax > STARTsample:
13723  STARTsample = ptmax
13724  i = 0
13725  while i < 6:
13726  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13727  i = i + 1
13728  if len(FFTresultB) == len(FFTmemoryB):
13729  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
13730  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13731  try:
13732  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
13733  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
13734  except:
13735  FFTmemoryB = FFTresultB
13736  PhaseMemoryB = PhaseB
13737 #
13738  TRACEsize = int(len(FFTresultA))
13739  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
13740  if SpectrumScreenStatus.get() > 0:
13741  STARTsample = int(StartFrequency / Fsample)
13742  else:
13743  STARTsample = 0
13744  if LoopNum.get() == 1:
13745  PhaseMemoryA = PhaseA
13746  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13747  if FSweepMode.get() == 1:
13748  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13749  if ptmax > STARTsample:
13750  STARTsample = ptmax
13751  i = 0
13752  while i < 6:
13753  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13754  i = i + 1
13755  if FSweepMode.get() == 2:
13756  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13757  if ptmax > STARTsample:
13758  STARTsample = ptmax
13759  i = 0
13760  while i < 6:
13761  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13762  i = i + 1
13763 
13764  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13765  if FSweepMode.get() == 1:
13766  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13767  if ptmax > STARTsample:
13768  STARTsample = ptmax
13769  i = 0
13770  while i < 6:
13771  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13772  i = i + 1
13773  if FSweepMode.get() == 2:
13774  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13775  if ptmax > STARTsample:
13776  STARTsample = ptmax
13777  i = 0
13778  while i < 6:
13779  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13780  i = i + 1
13781 #
13782  if len(FFTresultA) == len(FFTmemoryA):
13783  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
13784  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13785  try:
13786  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
13787  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
13788  except:
13789  FFTmemoryA = FFTresultA
13790  PhaseMemoryA = PhaseA
13791 #
13792  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
13793  FSweepAdB.append(numpy.amax(FFTresultA))
13794  FSweepBdB.append(numpy.amax(FFTresultB))
13795  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
13796  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
13797 
13798  TRACEresetFreq = False # Trace reset done
13799 
13800 def MakeFreqTrace(): # Update the grid and trace
13801  global FFTmemoryA, FFTresultA
13802  global FFTmemoryB, FFTresultB
13803  global FFTresultAWGA, FFTresultAWGB, ShowAWGASA, ShowAWGBSA
13804  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13805  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
13806  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
13807  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13808  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
13809  global PeakfreqA, PeakfreqB, Two_X_Sample
13810  global DBdivindex # Index value
13811  global DBdivlist # dB per division list
13812  global DBlevel # Reference level
13813  global GRHF,GRWF # Screenheight, Screenwidth
13814  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
13815  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13816  global STARTsample, STOPsample, LoopNum, FSweepMode, FreqTraceMode, SMPfft
13817  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
13818  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline, TAFline, TBFline
13819  global Vdiv # Number of vertical divisions
13820  global X0LF, Y0TF # Left top X value, Left top Y value
13821 
13822  # Set the TRACEsize variable
13823  TRACEsize = 0
13824  try:
13825  StartFrequency = float(StartFreqEntry.get())
13826  except:
13827  StartFreqEntry.delete(0,"end")
13828  StartFreqEntry.insert(0,100)
13829  StartFrequency = 100
13830  try:
13831  StopFrequency = float(StopFreqEntry.get())
13832  except:
13833  StopFreqEntry.delete(0,"end")
13834  StopFreqEntry.insert(0,50000)
13835  StopFrequency = 50000
13836  if StartFrequency > StopFrequency :
13837  StopFreqEntry.delete(0,"end")
13838  StopFreqEntry.insert(0,50000)
13839  StopFrequency = 50000
13840  if StopFrequency < StartFrequency :
13841  StopFreqEntry.delete(0,"end")
13842  StopFreqEntry.insert(0,50000)
13843  StopFrequency = 50000
13844  try:
13845  Phasecenter = int(PhCenFreqEntry.get())
13846  RelPhaseCenter.set(Phasecenter)
13847  except:
13848  PhCenFreqEntry.delete(0,"end")
13849  PhCenFreqEntry.insert(0,0)
13850  RelPhaseCenter.set(0)
13851  Phasecenter = 0
13852  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13853  if SAvertmaxEntry.get() == "10.0":
13854  SAvertmax = 10.0
13855  elif SAvertmaxEntry.get() == "1.0":
13856  SAvertmax = 1.0
13857  elif SAvertmaxEntry.get() == "0.1":
13858  SAvertmax = 0.1
13859  elif SAvertmaxEntry.get() == "10mV":
13860  SAvertmax = 1.0E-2
13861  elif SAvertmaxEntry.get() == "1mV":
13862  SAvertmax = 1.0E-3
13863  elif SAvertmaxEntry.get() == "100uV":
13864  SAvertmax = 1.0E-4
13865  elif SAvertmaxEntry.get() == "10uV":
13866  SAvertmax = 1.0E-5
13867  elif SAvertmaxEntry.get() == "1uV":
13868  SAvertmax = 1.0E-6
13869  elif SAvertmaxEntry.get() == "100nV":
13870  SAvertmax = 1.0E-7
13871  elif SAvertmaxEntry.get() == "10nV":
13872  SAvertmax = 1.0E-8
13873  else:
13874  SAvertmax = float(SAvertmaxEntry.get())
13875  if SAvertmax < 0.0: # negative values not allowed
13876  SAvertmaxEntry.delete(0,"end")
13877  SAvertmaxEntry.insert(0, "1mV")
13878  SAvertmax = 1.0E-3
13879  except:
13880  SAvertmaxEntry.delete(0,"end")
13881  SAvertmaxEntry.insert(0, "1mV")
13882  SAvertmax = 1.0E-3
13883  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13884  if SAvertminEntry.get() == "10.0":
13885  SAvertmin = 10.0
13886  elif SAvertminEntry.get() == "1.0":
13887  SAvertmin = 1.0
13888  elif SAvertminEntry.get() == "0.1":
13889  SAvertmin = 0.1
13890  elif SAvertminEntry.get() == "10mV":
13891  SAvertmin = 1.0E-2
13892  elif SAvertminEntry.get() == "1mV":
13893  SAvertmin = 1.0E-3
13894  elif SAvertminEntry.get() == "100uV":
13895  SAvertmin = 1.0E-4
13896  elif SAvertminEntry.get() == "10uV":
13897  SAvertmin = 1.0E-5
13898  elif SAvertminEntry.get() == "1uV":
13899  SAvertmin = 1.0E-6
13900  elif SAvertminEntry.get() == "100nV":
13901  SAvertmin = 1.0E-7
13902  elif SAvertminEntry.get() == "10nV":
13903  SAvertmin = 1.0E-8
13904  else:
13905  SAvertmin = float(SAvertminEntry.get())
13906  if SAvertmin < 0.0: # negative values not allowed
13907  SAvertminEntry.delete(0,"end")
13908  SAvertminEntry.insert(0, "1uV")
13909  SAvertmin = 1.0E-6
13910  except:
13911  SAvertminEntry.delete(0,"end")
13912  SAvertminEntry.insert(0, "1uV")
13913  SAvertmin = 1.0E-6
13914  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
13915  TRACEsize = len(FFTresultA) # Set the trace length
13916  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
13917  TRACEsize = len(FFTresultB)
13918  elif ShowAWGASA.get() > 0:
13919  TRACEsize = len(FFTresultAWGA)
13920  elif ShowAWGBSA.get() > 0:
13921  TRACEsize = len(FFTresultAWGB)
13922  #print(TRACEsize)
13923  if TRACEsize == 0: # If no trace, skip rest of this routine
13924  return()
13925  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
13926  PhaseA = PhaseMemoryA
13927  PhaseB = PhaseMemoryB
13928  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
13929  # Vertical conversion factors (level dBs) and border limits
13930  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13931  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
13932  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13933  YVc = float(Y0TF) + YVconv * SAvertmax
13934  Ymin = Y0TF # Minimum position of screen grid (top)
13935  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
13936  Yphconv = float(GRHF) / 360
13937  Yp = float(Y0TF) + Yphconv + 180
13938  # Horizontal conversion factors (frequency Hz) and border limits
13939  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13940  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13941  LogFStop = math.log10(StopFrequency)
13942  try:
13943  LogFStart = math.log10(StartFrequency)
13944  except:
13945  LogFStart = 0.0
13946  LogFpixel = (LogFStop - LogFStart) / GRWF
13947  #
13948  try:
13949  LogVStop = math.log10(SAvertmax)
13950  except:
13951  LogVStop = 0.0
13952  try:
13953  LogVStart = math.log10(SAvertmin)
13954  except:
13955  LogVStart = -10
13956  LogVpixel = (LogVStop - LogVStart) / GRHF
13957  #
13958  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
13959  STARTsample = int(math.ceil(STARTsample)) # First within screen range
13960 
13961  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
13962  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
13963 
13964  MAXsample = TRACEsize # Just an out of range check
13965  if STARTsample > (MAXsample - 1):
13966  STARTsample = MAXsample - 1
13967 
13968  if STOPsample > MAXsample:
13969  STOPsample = MAXsample
13970 
13971  T1Fline = []
13972  T2Fline = []
13973  TAFline = []
13974  TBFline = []
13975  T1Pline = []
13976  T2Pline = []
13977  TFMline = []
13978  n = STARTsample
13979  PeakIndexA = PeakIndexB = n
13980  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
13981  while n <= STOPsample:
13982  F = n * Fsample
13983  if HScale.get() == 1:
13984  try:
13985  LogF = math.log10(F) # convet to log Freq
13986  x = X0LF + (LogF - LogFStart)/LogFpixel
13987  except:
13988  x = X0LF
13989  else:
13990  x = X0LF + (F - StartFrequency) / Fpixel
13991  if ShowC1_VdB.get() == 1:
13992  T1Fline.append(int(x + 0.5))
13993  try:
13994  if SAVScale.get() == 0:
13995  if SAVPSD.get() == 1:
13996  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth))
13997  else:
13998  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
13999  ya = Yc - Yconv * dbA
14000  else:
14001  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14002  V = 10.0**(dbA/20.0)# convert back to RMS Volts
14003  if SAVPSD.get() == 1:
14004  V = V/math.sqrt(FBinWidth) # per root Hz
14005  if SAVScale.get() == 2:
14006  try:
14007  LogV = math.log10(V) # convet to log Volts
14008  ya = YVc - (LogV - LogVStart)/LogVpixel
14009  except:
14010  ya = YVc - YVconv * V
14011  else:
14012  ya = YVc - YVconv * V
14013  except:
14014  ya = Ymax
14015  if (ya < Ymin):
14016  ya = Ymin
14017  if (ya > Ymax):
14018  ya = Ymax
14019  if dbA > PeakdbA:
14020  PeakdbA = dbA
14021  PeakyA = int(ya + 0.5)
14022  PeakxA = int(x + 0.5)
14023  PeakfreqA = F
14024  PeakIndexA = n
14025  T1Fline.append(int(ya + 0.5))
14026  if ShowC2_VdB.get() == 1:
14027  T2Fline.append(int(x + 0.5))
14028  try:
14029  if SAVScale.get() == 0:
14030  if SAVPSD.get() == 1:
14031  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14032  else:
14033  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14034  yb = Yc - Yconv * dbB
14035  else:
14036  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
14037  V = 10.0**(dbB/20.0)# RMS Volts
14038  if SAVPSD.get() == 1:
14039  V = V/math.sqrt(FBinWidth) # per root Hz
14040  if SAVScale.get() == 2:
14041  try:
14042  LogV = math.log10(V) # convet to log Volts
14043  yb = YVc - (LogV - LogVStart)/LogVpixel
14044  except:
14045  yb = YVc - YVconv * V
14046  else:
14047  yb = YVc - YVconv * V
14048  except:
14049  yb = Ymax
14050  if (yb < Ymin):
14051  yb = Ymin
14052  if (yb > Ymax):
14053  yb = Ymax
14054  if dbB > PeakdbB:
14055  PeakdbB = dbB
14056  PeakyB = int(yb + 0.5)
14057  PeakxB = int(x + 0.5)
14058  PeakfreqB = F
14059  PeakIndexB = n
14060  T2Fline.append(int(yb + 0.5))
14061  if ShowAWGASA.get() > 0:
14062  TAFline.append(int(x + 0.5))
14063  try:
14064  if SAVPSD.get() == 1:
14065  dbA = 10 * math.log10(float(FFTresultAWGA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14066  else:
14067  dbA = 10 * math.log10(float(FFTresultAWGA[n])) # Convert power to DBs
14068  ya = Yc - Yconv * dbA
14069  except:
14070  ya = Ymax
14071  if (ya < Ymin):
14072  ya = Ymin
14073  if (ya > Ymax):
14074  ya = Ymax
14075  TAFline.append(int(ya + 0.5))
14076  if ShowAWGBSA.get() > 0:
14077  TBFline.append(int(x + 0.5))
14078  try:
14079  if SAVPSD.get() == 1:
14080  dbA = 10 * math.log10(float(FFTresultAWGB[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14081  else:
14082  dbA = 10 * math.log10(float(FFTresultAWGb[n])) # Convert power to DBs
14083  ya = Yc - Yconv * dbA
14084  except:
14085  ya = Ymax
14086  if (ya < Ymin):
14087  ya = Ymin
14088  if (ya > Ymax):
14089  ya = Ymax
14090  TBFline.append(int(ya + 0.5))
14091  if ShowC1_P.get() == 1:
14092  T1Pline.append(int(x + 0.5))
14093  if FSweepMode.get() > 0:
14094  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
14095  else:
14096  RelPhase = PhaseA[n]-PhaseB[n]
14097  RelPhase = RelPhase - Phasecenter
14098  if RelPhase > 180:
14099  RelPhase = RelPhase - 360
14100  elif RelPhase < -180:
14101  RelPhase = RelPhase + 360
14102  if Two_X_Sample.get() == 0:
14103  PhErr = 0.0018 * n * Fsample # calculate phase error due half sample period offset
14104  RelPhase = RelPhase + PhErr - 12.0
14105  else:
14106  RelPhase = RelPhase - 9.0
14107  ya = Yp - Yphconv * RelPhase
14108  T1Pline.append(int(ya + 0.5))
14109  if ShowC2_P.get() == 1:
14110  T2Pline.append(int(x + 0.5))
14111  if FSweepMode.get() > 0:
14112  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
14113  else:
14114  RelPhase = PhaseB[n]-PhaseA[n]
14115  RelPhase = RelPhase - Phasecenter
14116  if RelPhase > 180:
14117  RelPhase = RelPhase - 360
14118  elif RelPhase < -180:
14119  RelPhase = RelPhase + 360
14120  if Two_X_Sample.get() == 0:
14121  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14122  RelPhase = RelPhase - PhErr - 12.0
14123  else:
14124  RelPhase = RelPhase - 9.0
14125  ya = Yp - Yphconv * RelPhase
14126  T2Pline.append(int(ya + 0.5))
14127  if ShowMathSA.get() > 0:
14128  TFMline.append(int(x + 0.5))
14129  if SAVPSD.get() == 1:
14130  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14131  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14132  else:
14133  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14134  dbB = 10 * math.log10(float(FFTresultB[n]))
14135  if ShowMathSA.get() == 1:
14136  MdB = dbA - dbB
14137  elif ShowMathSA.get() == 2:
14138  MdB = dbB - dbA
14139  yb = Yc - Yconv * MdB
14140  if (yb < Ymin):
14141  yb = Ymin
14142  if (yb > Ymax):
14143  yb = Ymax
14144  if MdB > PeakMdb:
14145  PeakMdb = MdB
14146  PeakyM = int(yb + 0.5)
14147  PeakxM = int(x + 0.5)
14148  PeakfreqM = F
14149  TFMline.append(int(yb + 0.5))
14150  n = n + 1
14151 #
14152 # make Bode Plot Traces
14153 def MakeBodeTrace(): # Update the grid and trace
14154  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
14155  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
14156  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14157  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14158  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
14159  global DBdivindexBP # Index value
14160  global DBdivlist # dB per division list
14161  global DBlevelBP # Reference level
14162  global GRHBP # Screenheight
14163  global GRWBP # Screenwidth
14164  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
14165  global StartBodeEntry, StopBodeEntry, SMPfft
14166  global STARTsample, STOPsample, LoopNum, FSweepMode
14167  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14168  global TAFline, TBFline, TBPMline, TAPline, TBPline
14169  global Vdiv # Number of vertical divisions
14170  global X0LBP # Left top X value
14171  global Y0TBP # Left top Y value
14172  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
14173  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
14174  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14175 
14176  # Set the TRACEsize variable
14177  TRACEsize = 0
14178  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
14179  TRACEsize = len(FStep) # Set the trace length
14180  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
14181  TRACEsize = len(FStep)
14182  if TRACEsize == 0: # If no trace, skip rest of this routine
14183  return()
14184  #
14185  try:
14186  EndFreq = float(StopBodeEntry.get())
14187  except:
14188  StopBodeEntry.delete(0,"end")
14189  StopBodeEntry.insert(0,10000)
14190  EndFreq = 10000
14191  try:
14192  BeginFreq = float(StartBodeEntry.get())
14193  except:
14194  StartBodeEntry.delete(0,"end")
14195  StartBodeEntry.insert(0,100)
14196  BeginFreq = 100
14197  try:
14198  Phasecenter = float(PhCenBodeEntry.get())
14199  RelPhaseCenter.set(Phasecenter)
14200  except:
14201  PhCenBodeEntry.delete(0,"end")
14202  PhCenBodeEntry.insert(0,0)
14203  RelPhaseCenter.set(0)
14204  Phasecenter = 0
14205  try:
14206  Impedcenter = float(ImCenBodeEntry.get())
14207  ImpedanceCenter.set(Impedcenter)
14208  except:
14209  ImCenBodeEntry.delete(0,"end")
14210  ImCenBodeEntry.insert(0,0)
14211  ImpedanceCenter.set(0)
14212  Impedcenter = 0
14213  #
14214  HalfSAMPLErate = SAMPLErate/2
14215  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
14216  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
14217  CurrentFreqX = X0LBP + 14
14218  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
14219  # Vertical conversion factors (level dBs) and border limits
14220  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14221  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14222  Ymin = Y0TBP # Minimum position of screen grid (top)
14223  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
14224  Yphconv = float(GRHBP) / 360 # degrees per pixel
14225  Yp = float(Y0TBP) + Yphconv + 180
14226  x1 = X0LBP + 14
14227  # Horizontal conversion factors (frequency Hz) and border limits
14228  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14229  LogFStop = math.log10(EndFreq)
14230  try:
14231  LogFStart = math.log10(BeginFreq)
14232  except:
14233  LogFStart = 0.0
14234  LogFpixel = (LogFStop - LogFStart) / GRWBP
14235  TAFline = []
14236  TBFline = []
14237  TAPline = []
14238  TBPline = []
14239  TIARline = []
14240  TIAXline = []
14241  TIAMagline = []
14242  TIAAngline = []
14243  TBPMline = []
14244  PeakdbA = -200
14245  PeakdbB = -200
14246  PeakMdb = -200
14247  n = 0
14248  for n in range(len(FSweepAdB)): # while n < len(FStep):
14249  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14250  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14251  else:
14252  F = FBins[int(FStep[0])]
14253  if F >= BeginFreq and F <= EndFreq:
14254  if HScaleBP.get() == 1:
14255  try:
14256  LogF = math.log10(F) # convet to log Freq
14257  x = x1 + (LogF - LogFStart)/LogFpixel
14258  except:
14259  x = x1
14260  else:
14261  x = x1 + (F - BeginFreq) / Fpixel
14262  CurrentFreqX = x
14263  if ShowCA_VdB.get() == 1:
14264  TAFline.append(int(x + 0.5))
14265  try:
14266  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14267  ya = Yc - Yconv * dbA
14268  except:
14269  ya = Ymax
14270  if (ya < Ymin):
14271  ya = Ymin
14272  if (ya > Ymax):
14273  ya = Ymax
14274  if dbA > PeakdbA:
14275  PeakdbA = dbA
14276  PeakyA = int(ya + 0.5)
14277  PeakxA = int(x + 0.5)
14278  PeakfreqA = F
14279  TAFline.append(int(ya + 0.5))
14280  if ShowCB_VdB.get() == 1:
14281  TBFline.append(int(x + 0.5))
14282  try:
14283  dbB = 10 * math.log10(float(FSweepBdB[n]))
14284  yb = Yc - Yconv * dbB
14285  except:
14286  yb = Ymax
14287  if (yb < Ymin):
14288  yb = Ymin
14289  if (yb > Ymax):
14290  yb = Ymax
14291  if dbB > PeakdbB:
14292  PeakdbB = dbB
14293  PeakyB = int(yb + 0.5)
14294  PeakxB = int(x + 0.5)
14295  PeakfreqB = F
14296  TBFline.append(int(yb + 0.5))
14297  if ShowCA_P.get() == 1:
14298  TAPline.append(int(x + 0.5))
14299  RelPhase = FSweepAPh[n] - FSweepBPh[n]
14300  RelPhase = RelPhase - Phasecenter
14301  if RelPhase > 180:
14302  RelPhase = RelPhase - 360
14303  elif RelPhase < -180:
14304  RelPhase = RelPhase + 360
14305  if Two_X_Sample.get() == 0:
14306  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14307  RelPhase = RelPhase + PhErr - PhaseOffset1x
14308  else:
14309  RelPhase = RelPhase - PhaseOffset2x
14310  ya = Yp - Yphconv * RelPhase
14311  TAPline.append(int(ya + 0.5))
14312  if ShowCB_P.get() == 1:
14313  TBPline.append(int(x + 0.5))
14314  RelPhase = FSweepBPh[n] - FSweepAPh[n]
14315  RelPhase = RelPhase - Phasecenter
14316  if RelPhase > 180:
14317  RelPhase = RelPhase - 360
14318  elif RelPhase < -180:
14319  RelPhase = RelPhase + 360
14320  if Two_X_Sample.get() == 0:
14321  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14322  RelPhase = RelPhase - PhErr - PhaseOffset1x
14323  else:
14324  RelPhase = RelPhase - PhaseOffset2x
14325  ya = Yp - Yphconv * RelPhase
14326  TBPline.append(int(ya + 0.5))
14327  if ShowMathBP.get() > 0:
14328  TBPMline.append(int(x + 0.5))
14329  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14330  dbB = 10 * math.log10(float(FSweepBdB[n]))
14331  if ShowMathBP.get() == 1:
14332  MdB = dbA - dbB
14333  elif ShowMathBP.get() == 2:
14334  MdB = dbB - dbA
14335  yb = Yc - Yconv * MdB
14336  if (yb < Ymin):
14337  yb = Ymin
14338  if (yb > Ymax):
14339  yb = Ymax
14340  if MdB > PeakMdb:
14341  PeakMdb = MdB
14342  PeakyM = int(yb + 0.5)
14343  PeakxM = int(x + 0.5)
14344  PeakfreqM = F
14345  TBPMline.append(int(yb + 0.5))
14346 # draw impedance trace if necessary
14347  if NetworkScreenStatus.get() > 0:
14348  ycenter = Y0TBP + (GRHBP/2)
14349  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
14350  n = 0
14351  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
14352  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14353  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14354  else:
14355  F = FBins[int(FStep[0])]
14356  if F >= BeginFreq and F <= EndFreq:
14357  if HScaleBP.get() == 1:
14358  try:
14359  LogF = math.log10(F) # convet to log Freq
14360  x = x1 + (LogF - LogFStart)/LogFpixel
14361  except:
14362  x = x1
14363  else:
14364  x = x1 + (F - BeginFreq) / Fpixel
14365  if Show_Rseries.get() == 1:
14366  TIARline.append(int(x + 0.5))
14367  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
14368  if (y1 < Ymin):
14369  y1 = Ymin
14370  if (y1 > Ymax):
14371  y1 = Ymax
14372  TIARline.append(y1)
14373  if Show_Xseries.get() == 1:
14374  TIAXline.append(int(x + 0.5))
14375  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
14376  if (y1 < Ymin):
14377  y1 = Ymin
14378  if (y1 > Ymax):
14379  y1 = Ymax
14380  TIAXline.append(y1)
14381  if Show_Magnitude.get() == 1:
14382  TIAMagline.append(int(x + 0.5))
14383  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
14384  if (y1 < Ymin):
14385  y1 = Ymin
14386  if (y1 > Ymax):
14387  y1 = Ymax
14388  TIAMagline.append(y1)
14389  if Show_Angle.get() == 1:
14390  TIAAngline.append(int(x + 0.5))
14391  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
14392  if (y1 < Ymin):
14393  y1 = Ymin
14394  if (y1 > Ymax):
14395  y1 = Ymax
14396  TIAAngline.append(y1)
14397 #
14398 def MakeBodeScreen(): # Update the screen with traces and text
14399  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
14400  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14401  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14402  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14403  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14404  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14405  global COLORgrid # The colors
14406  global COLORsignalband, COLORtext
14407  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
14408  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
14409  global DBdivindexBP # Index value
14410  global DBdivlist # dB per division list
14411  global DBlevelBP # Reference level
14412  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14413  global X0LBP # Left top X value
14414  global Y0TBP # Left top Y value
14415  global GRWBP # Screenwidth
14416  global GRHBP # Screenheight
14417  global FontSize
14418  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14419  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
14420  global SMPfft # number of FFT samples
14421  global StartBodeEntry, StopBodeEntry
14422  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
14423  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
14424  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14425  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
14426  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
14427  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
14428  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
14429  global TAPRline, TBPRline
14430  global TRACEaverage # Number of traces for averageing
14431  global FreqTraceMode # 1 normal 2 max 3 average
14432  global Vdiv, ResScale # Number of vertical divisions
14433  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14434  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
14435 
14436  # Delete all items on the screen
14437  MarkerFreqNum = 0
14438  Bodeca.delete(ALL) # remove all items
14439 
14440  try:
14441  EndFreq = float(StopBodeEntry.get())
14442  except:
14443  StopBodeEntry.delete(0,"end")
14444  StopBodeEntry.insert(0,10000)
14445  EndFreq = 10000
14446  try:
14447  BeginFreq = float(StartBodeEntry.get())
14448  except:
14449  StartBodeEntry.delete(0,"end")
14450  StartBodeEntry.insert(0,100)
14451  BeginFreq = 100
14452  try:
14453  Phasecenter = float(PhCenBodeEntry.get())
14454  RelPhaseCenter.set(Phasecenter)
14455  except:
14456  PhCenBodeEntry.delete(0,"end")
14457  PhCenBodeEntry.insert(0,0)
14458  RelPhaseCenter.set(0)
14459  Phasecenter = 0
14460  try:
14461  Impedcenter = float(ImCenBodeEntry.get())
14462  ImpedanceCenter.set(Impedcenter)
14463  except:
14464  ImCenBodeEntry.delete(0,"end")
14465  ImCenBodeEntry.insert(0,0)
14466  ImpedanceCenter.set(0)
14467  Impedcenter = 0
14468  #
14469  # Draw horizontal grid lines
14470  i = 0
14471  x1 = X0LBP + 14
14472  x2 = x1 + GRWBP
14473  while (i <= Vdiv.get()):
14474  y = Y0TBP + i * GRHBP/Vdiv.get()
14475  Dline = [x1,y,x2,y]
14476  if i == 0 or i == Vdiv.get():
14477  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14478  else:
14479  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14480  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
14481  Vaxis_label = str(Vaxis_value)
14482  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14483  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
14484  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
14485  Vaxis_label = str(Vaxis_value)
14486  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
14487  if NetworkScreenStatus.get() > 0:
14488  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
14489  RperDiv = float(ResScale.get())
14490  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
14491  if Vaxis_value > 500 or Vaxis_value < -500:
14492  Vaxis_value = Vaxis_value/1000.0
14493  if Vaxis_value > 5 or Vaxis_value < -5:
14494  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
14495  else:
14496  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
14497  elif Vaxis_value > 50 or Vaxis_value < -50:
14498  Vaxis_label = ' {0:.1f} '.format(Vaxis_value)
14499  elif Vaxis_value > 5 or Vaxis_value < -55:
14500  Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
14501  else:
14502  Vaxis_label = ' {0:.3f} '.format(Vaxis_value)
14503  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
14504  i = i + 1
14505  # Draw vertical grid lines
14506  i = 0
14507  y1 = Y0TBP
14508  y2 = Y0TBP + GRHBP
14509  if HScaleBP.get() == 1:
14510  F = 1.0
14511  LogFStop = math.log10(EndFreq)
14512  try:
14513  LogFStart = math.log10(BeginFreq)
14514  except:
14515  LogFStart = 0.0
14516  LogFpixel = (LogFStop - LogFStart) / GRWBP
14517  # draw left and right edges
14518  while F <= EndFreq:
14519  if F >= BeginFreq:
14520  try:
14521  LogF = math.log10(F) # convet to log Freq
14522  x = x1 + (LogF - LogFStart)/LogFpixel
14523  except:
14524  x = x1
14525  Dline = [x,y1,x,y2]
14526  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
14527  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14528  axis_label = str(F)
14529  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14530  else:
14531  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14532 
14533  if F < 10:
14534  F = F + 1
14535  elif F < 100:
14536  F = F + 10
14537  elif F < 1000:
14538  F = F + 100
14539  elif F < 1000:
14540  F = F + 100
14541  elif F < 10000:
14542  F = F + 1000
14543  elif F < 100000:
14544  F = F + 10000
14545  elif F < 200000:
14546  F = F + 10000
14547  else:
14548  Freqdiv = (EndFreq - BeginFreq) / 10
14549  while (i < 11):
14550  x = x1 + i * GRWBP/10
14551  Dline = [x,y1,x,y2]
14552  if i == 0 or i == 10:
14553  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14554  else:
14555  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14556  axis_value = BeginFreq + (i * Freqdiv)
14557  axis_label = str(axis_value)
14558  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14559  i = i + 1
14560  # Draw X - Y cursors if needed
14561  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14562  LogFStop = math.log10(EndFreq)
14563  try:
14564  LogFStart = math.log10(BeginFreq)
14565  except:
14566  LogFStart = 0.0
14567  LogFpixel = (LogFStop - LogFStart) / GRWBP
14568  if ShowBPCur.get() > 0:
14569  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
14570  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14571  # Horizontal conversion factors (frequency Hz) and border limits
14572  if HScaleBP.get() == 1:
14573  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
14574  else:
14575  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
14576  XFString = ' {0:.2f} '.format(xfreq)
14577  V_label = XFString + " Hz"
14578  Bodeca.create_text(BPCursor, Y0TBP+GRHBP+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14579  #Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14580 #
14581  if ShowBdBCur.get() > 0:
14582  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
14583  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14584  if ShowBdBCur.get() == 1:
14585  # Vertical conversion factors (level dBs) and border limits
14586  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14587  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14588  yvdB = ((Yc-BdBCursor)/Yconv)
14589  VdBString = ' {0:.1f} '.format(yvdB)
14590  V_label = VdBString + " dBV"
14591  else:
14592  # Vertical conversion factors (level degrees) and border limits
14593  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
14594  Yc = float(Y0TBP) # Yc is the 180 degree position
14595  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
14596  VdBString = ' {0:.1f} '.format(yvdB)
14597  V_label = VdBString + " Deg"
14598  Bodeca.create_text(x1+GRWBP+1, BdBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14599  #Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14600  #
14601  SmoothBool = SmoothCurvesBP.get()
14602  # Draw traces
14603  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
14604  # Write the trace CHA
14605  if OverRangeFlagA == 1:
14606  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14607  else:
14608  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14609  if ShowMarkerBP.get() == 1:
14610  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
14611  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14612  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
14613  # Write the trace CHB
14614  if OverRangeFlagB == 1:
14615  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14616  else:
14617  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14618  if ShowMarkerBP.get() == 1:
14619  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
14620  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
14621  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
14622  # Write the phase trace A-B
14623  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14624  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
14625  # Write the phase trace A-B
14626  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14627  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
14628  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14629  if ShowMarkerBP.get() == 1:
14630  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
14631  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
14632  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
14633  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14634  if ShowMarkerBP.get() == 1:
14635  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
14636  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
14637  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
14638  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14639  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
14640  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14641  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
14642  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14643  if ShowMarkerBP.get() == 1:
14644  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
14645  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
14646  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
14647  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14648  if ShowMarkerBP.get() == 1:
14649  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
14650  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
14651  if Show_Rseries.get() == 1 and len(TIARline) > 4:
14652  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14653  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
14654  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14655  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
14656  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14657  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
14658  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14659  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
14660  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14661  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
14662  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14663  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
14664  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14665  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
14666  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14667 
14668  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
14669  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
14670  if HScaleBP.get() == 1:
14671  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
14672  else:
14673  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
14674  XFString = ' {0:.0f} '.format(xfreq)
14675  V_label = XFString + " Hz"
14676  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14677  # General information on top of the grid
14678 
14679  txt = " Sample rate: " + str(SAMPLErate)
14680  txt = txt + " FFT samples: " + str(SMPfft)
14681 
14682  txt = txt + " " + FFTwindowname
14683 
14684  x = X0LBP
14685  y = 12
14686  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14687 
14688  # Start and stop frequency and dB/div and trace mode
14689  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
14690  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
14691  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
14692  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
14693 
14694  x = X0LBP
14695  y = Y0TBP+GRHBP+23
14696  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14697 
14698  if FreqTraceMode.get() == 1:
14699  txt ="Normal mode "
14700 
14701  if FreqTraceMode.get() == 2:
14702  txt = "Peak hold mode "
14703 
14704  if FreqTraceMode.get() == 3:
14705  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
14706 
14707  if ZEROstuffing.get() > 0:
14708  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
14709  # Runstatus and level information
14710  if (RUNstatus.get() == 0):
14711  txt = txt + " Stopped "
14712  else:
14713  if BodeDisp.get() == 1:
14714  txt = txt + " Running "
14715  else:
14716  txt = txt + " Display off "
14717  if FSweepMode.get() > 0:
14718  txt = txt + " Freq Step = " + str(LoopNum.get())
14719  x = X0LBP
14720  y = Y0TBP+GRHBP+34
14721  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14722 
14723 # Impedance analyzer routines -----
14724 def UpdateIAAll(): # Update Data, trace and screen
14725  global FFTBuffA, FFTBuffB
14726  global SMPfft
14727 
14728  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14729  return
14730 
14731  MakeIATrace() # Update the traces
14732  UpdateIAScreen() # Update the screen
14733 
14734 def UpdateIATrace(): # Update trace and screen
14735  MakeIATrace() # Update traces
14736  UpdateIAScreen() # Update the screen
14737 
14738 def UpdateIAScreen(): # Update screen with trace and text
14739  MakeIAScreen() # Update the screen
14740  root.update() # Activate updated screens
14741 #
14743 
14744 # Input Variables
14745  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14746  #(VZ/VA)from vector voltmeter
14747  # global VVangle # angle in degrees between VZ and VA
14748  global RsystemEntry # resistance of series resistor or power divider
14749 # Computed outputs
14750  # global VVangleCosine # cosine of vector voltmeter angle
14751  global ImpedanceMagnitude # in ohms
14752  global ImpedanceAngle # in degrees
14753  global ImpedanceRseries, ImpedanceXseries # in ohms
14754  global IA_Ext_Conf
14755 
14756  DEG2RAD = (math.pi / 180.0)
14757  SMALL = 1E-20
14758  try:
14759  ResValue = float(RsystemEntry.get())
14760  except:
14761  ResValue = 1000.0
14762 
14763  VA = math.pow(10,(PeakdbA/20))
14764  VB = math.pow(10,(PeakdbB/20))
14765  VVangleCosine = math.cos(math.radians(PeakRelPhase))
14766  if IA_Ext_Conf.get() == 1:
14767  VAB = math.pow(10,(PeakdbAB/20))
14768  VZ = VAB # VZ=VA-VB
14769  # VI = VB
14770  else:
14771  VZ = VB # VZ=VB
14772  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
14773  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
14774  Za = ResValue * VA / VI
14775  ImpedanceRseries = Za * costheta - ResValue
14776  ImpedanceMagnitude = ResValue * VZ / VI
14777  # don't try to take square root of a negative number)
14778  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
14779 
14780  if(PeakRelPhase < 0.0):
14781  ImpedanceXseries = -ImpedanceXseries
14782  if IA_Ext_Conf.get() == 1:
14783  ImpedanceRseries = -ImpedanceRseries
14784  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
14785 #
14786 def MakeIATrace(): # Update the grid and trace
14787  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
14788  global FFTmemoryB, FFTresultB
14789  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14790  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14791  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
14792  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
14793  global DBdivindex # Index value
14794  global DBdivlist # dB per division list
14795  global DBlevel # Reference level
14796  global GRHIA # Screenheight
14797  global GRWIA # Screenwidth
14798  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SMPfft
14799  global STARTsample, STOPsample, LoopNum, FSweepMode
14800  global TRACEmode, Two_X_Sample, IA_Ext_Conf
14801  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
14802  global Vdiv # Number of vertical divisions
14803  global X0LIA # Left top X value
14804  global Y0TIA # Left top Y value
14805  global ImpedanceMagnitude # in ohms
14806  global ImpedanceAngle # in degrees
14807  global ImpedanceRseries, ImpedanceXseries # in ohms
14808 
14809  # Set the TRACEsize variable
14810  TRACEsize = len(FFTresultA) # Set the trace length
14811 
14812  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14813  # Horizontal conversion factors (frequency Hz) and border limits
14814  STARTsample = 0 # First sample in FFTresult[] that is used
14815  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14816  if Two_X_Sample.get() == 0:
14817  STOPsample = (SAMPLErate * 0.45) / Fsample # Last sample in FFTresult[] that is used
14818  else:
14819  STOPsample = (SAMPLErate * 0.45) / Fsample
14820  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14821 #
14822  RMScorr = 1.0 / SMPfft # For VOLTAGE!
14823  Powcorr = RMScorr **2 # vpktage squared For POWER!
14824  try:
14825  GainCorrection = float(eval(GainCorEntry.get()))
14826  except:
14827  GainCorEntry.delete(0,END)
14828  GainCorEntry.insert(0, GainCorrection)
14829 
14830  try:
14831  PhaseCorrection = float(eval(PhaseCorEntry.get()))
14832  except:
14833  PhaseCorEntry.delete(0,END)
14834  PhaseCorEntry.insert(0, PhaseCorrection)
14835 
14836  MAXsample = TRACEsize # Just an out of range check
14837  if STARTsample > (MAXsample - 1):
14838  STARTsample = MAXsample - 1
14839 
14840  if STOPsample > MAXsample:
14841  STOPsample = MAXsample - 1
14842 
14843  n = STARTsample
14844  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
14845  PeakphaseA = PhaseA[n]
14846  PeakphaseB = PhaseB[n]
14847  #PeakphaseAB = PhaseAB[n]
14848  PeakSample = n
14849 
14850  PeakdbA = 10 * math.log10(float(FFTresultA[n]))
14851  PeakdbB = 10 * math.log10(float(FFTresultB[n]))
14852  PeakMdb = PeakdbA - PeakdbB
14853  if IA_Ext_Conf.get() == 1:
14854  PeakdbAB = 10 * math.log10(float(FFTresultAB[n]))
14855  while n <= STOPsample:
14856  F = n * Fsample
14857  try:
14858  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs, except for log(0) error
14859  except:
14860  dbA = -200
14861  if dbA > PeakdbA:
14862  PeakdbA = dbA
14863  PeakfreqA = F
14864  PeakphaseA = PhaseA[n]
14865  PeakSample = n
14866 
14867  try:
14868  dbB = 10 * math.log10(float(FFTresultB[n]))
14869  except:
14870  dbB = -200
14871  if dbB > PeakdbB:
14872  PeakdbB = dbB
14873  PeakfreqB = F
14874  PeakphaseB = PhaseB[n]
14875 
14876  if IA_Ext_Conf.get() == 1:
14877  try:
14878  dbAB = 10 * math.log10(float(FFTresultAB[n]))
14879  except:
14880  dbAB = -200
14881  if dbAB > PeakdbAB:
14882  PeakdbAB = dbAB
14883  PeakphaseAB = PhaseAB[n]
14884  RelPhase = PhaseA[n]-PhaseB[n]
14885  if RelPhase > 180:
14886  RelPhase = RelPhase - 360
14887  elif RelPhase < -180:
14888  RelPhase = RelPhase + 360
14889  if Two_X_Sample.get() == 0:
14890  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14891  RelPhase = RelPhase + PhErr - 12.0
14892  else:
14893  RelPhase = RelPhase - 9.0
14894  n = n + 1
14895  if IA_Ext_Conf.get() == 1:
14896  PeakRelPhase = PeakphaseAB-PeakphaseA
14897  else:
14898  PeakRelPhase = PeakphaseB-PeakphaseA
14899 #
14900  if PeakRelPhase > 180:
14901  PeakRelPhase = PeakRelPhase - 360
14902  elif PeakRelPhase < -180:
14903  PeakRelPhase = PeakRelPhase + 360
14904  if Two_X_Sample.get() == 0:
14905  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
14906  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
14907  else:
14908  PeakRelPhase = PeakRelPhase + PhaseCorrection
14909  PeakdbB = PeakdbB + GainCorrection
14910  DoImpedance()
14911 
14913 def MakeIAScreen(): # Update the screen with traces and text
14914  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
14915  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14916  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
14917  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14918  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14919  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14920  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry, CapZeroEntry
14921  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
14922  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
14923  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
14924  global ResScale, DisplaySeries # Ohms per div
14925  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14926  global X0LIA # Left top X value
14927  global Y0TIA # Left top Y value
14928  global GRWIA # Screenwidth
14929  global GRHIA # Screenheight
14930  global FontSize, IAGridType
14931  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14932  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
14933  global SMPfft # number of FFT samples
14934  global TRACEaverage # Number of traces for averageing
14935  global FreqTraceMode # 1 normal 2 max 3 average
14936  global Vdiv # Number of vertical divisions
14937  global ImpedanceMagnitude # in ohms
14938  global ImpedanceAngle # in degrees
14939  global ImpedanceRseries, ImpedanceXseries, Cseries # in ohms / uF
14940  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
14941  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesC
14942 
14943  # Delete all items on the screen
14944  IAca.delete(ALL) # remove all items
14945  SmoothBool = SmoothCurvesBP.get()
14946  Cparallel = 0.0
14947  Rparallel = 0.0
14948  Lparallel = 0.0
14949  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14950  xright = 10 + GRWIA/2 + ( Vdiv.get() * Radius ) # 5
14951  OhmsperPixel = float(ResScale.get())/Radius
14952  TRadius = Radius * Vdiv.get() # 5
14953  xcenter = GRWIA/2
14954  ycenter = GRHIA/2
14955  if IAGridType.get() == 0:
14956  # Draw circular grid lines
14957  i = 1
14958  xcenter = GRWIA/2
14959  ycenter = GRHIA/2
14960  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14961  OhmsperPixel = float(ResScale.get())/Radius
14962  TRadius = Radius * Vdiv.get() # 5
14963  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
14964  while (i <= Vdiv.get()):
14965  x0 = xcenter - ( i * Radius )
14966  x1 = xcenter + ( i * Radius )
14967  y0 = ycenter - ( i * Radius )
14968  y1 = ycenter + ( i * Radius )
14969  axisvalue = float(ResScale.get()) * i
14970  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14971  axisvalue = axisvalue / 1000
14972  ResTxt = '{0:.1f}'.format(axisvalue)
14973  axis_label = str(ResTxt) + "K"
14974  elif axisvalue >= 100.0 or axisvalue <= -100.0:
14975  ResTxt = '{0:.1f}'.format(axisvalue)
14976  axis_label = str(ResTxt)
14977  elif axisvalue >= 10.0 or axisvalue <= -10.0:
14978  ResTxt = '{0:.2f}'.format(axisvalue)
14979  axis_label = str(ResTxt)
14980  else:
14981  ResTxt = '{0:.3f}'.format(axisvalue)
14982  axis_label = str(ResTxt)
14983  IAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
14984  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
14985  IAca.create_text(xright, y0, text=axis_label, fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14986  #
14987  i = i + 1
14988  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
14989  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
14990  RAngle = math.radians(45)
14991  y = TRadius*math.sin(RAngle)
14992  x = TRadius*math.cos(RAngle)
14993  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14994  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14995  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
14996  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14997  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
14998  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
14999  else:
15000  # Draw horizontal grid lines
15001  i = 0 - Vdiv.get()
15002  j = 0
15003  x1 = X0LIA
15004  x2 = X0LIA + TRadius * 2
15005  xcenter = x1 + (TRadius)
15006  OhmsperPixel = float(ResScale.get())/Radius
15007  while (i <= Vdiv.get()):
15008  y = Y0TIA + j * (TRadius/Vdiv.get())
15009  Dline = [x1,y,x2,y]
15010  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15011  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15012  else:
15013  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15014  axisvalue = float(ResScale.get()) * -i
15015  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15016  axisvalue = axisvalue / 1000
15017  ResTxt = '{0:.1f}'.format(axisvalue)
15018  axis_label = str(ResTxt) + "K"
15019  else:
15020  ResTxt = '{0:.0f}'.format(axisvalue)
15021  axis_label = str(ResTxt)
15022  IAca.create_text(x1-3, y, text=axis_label, fill=COLORtrace6, anchor="e", font=("arial", FontSize ))
15023  i = i + 1
15024  j = j + 1
15025  # Draw vertical grid lines
15026  i = 0 - Vdiv.get()
15027  j = 0
15028  y1 = Y0TIA
15029  y2 = Y0TIA + TRadius * 2
15030  ycenter = y1 + (TRadius)
15031  # "\n".join(axis_label)
15032  while (i <= Vdiv.get()): #
15033  x = x1 + j * (TRadius/Vdiv.get())
15034  Dline = [x,y1,x,y2]
15035  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
15036  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15037  else:
15038  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
15039  axisvalue = float(ResScale.get()) * i
15040  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
15041  axisvalue = axisvalue / 1000
15042  ResTxt = '{0:.1f}'.format(axisvalue)
15043  axis_label = str(ResTxt) + "K"
15044  else:
15045  ResTxt = '{0:.0f}'.format(axisvalue)
15046  axis_label = str(ResTxt)
15047  IAca.create_text(x, y2+3, text=axis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
15048  i = i + 1
15049  j = j + 1
15050 # Draw traces
15051  # Add saved line if there
15052  if IASweepSaved.get() > 0:
15053  if len(TIAMRline) > 4:
15054  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15055 #
15056  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
15057  if x1 > 1500:
15058  x1 = xright
15059  elif x1 < -500:
15060  x1 = xcenter - xright
15061  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
15062  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
15063  if y1 > 1500:
15064  y1 = xright
15065  elif y1 < -500:
15066  y1 = ycenter - xright
15067  xmag = x1
15068  ymag = y1
15069  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
15070  MagRadius = ImpedanceMagnitude / OhmsperPixel
15071  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
15072  if y1 > 1500:
15073  y1 = xright
15074  elif y1 < -500:
15075  y1 = ycenter - xright
15076  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
15077  if x1 > 1500:
15078  x1 = xright
15079  elif x1 < -500:
15080  x1 = xcenter - xright
15081  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
15082 #
15083  TIAMline = []
15084  if len(NSweepSeriesMag) > 2:
15085  index = 0
15086  while index < len(NSweepSeriesMag):
15087  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
15088  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
15089  if y1 > 1500:
15090  y1 = xright
15091  elif y1 < -500:
15092  y1 = ycenter - xright
15093  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
15094  if x1 > 1500:
15095  x1 = xright
15096  elif x1 < -500:
15097  x1 = xcenter - xright
15098  TIAMline.append(x1)
15099  TIAMline.append(y1)
15100  index = index + 1
15101  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15102 # display warning if input out of range
15103  if OverRangeFlagA == 1:
15104  x = X0LIA+GRWIA+10
15105  y = Y0TIA+GRHIA-40
15106  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15107  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15108  if OverRangeFlagB == 1:
15109  x = X0LIA+GRWIA+10
15110  y = Y0TIA+GRHIA-10
15111  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15112  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15113  # General information on top of the grid
15114 
15115  txt = " Sample rate: " + str(SAMPLErate)
15116  txt = txt + " FFT samples: " + str(SMPfft)
15117 
15118  txt = txt + " " + FFTwindowname
15119  if NetworkScreenStatus.get() > 0:
15120  txt = txt + " Sweep ON"
15121  else:
15122  txt = txt + " Sweep OFF"
15123  x = X0LIA
15124  y = 12
15125  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15126  #
15127  x = X0LIA + GRWIA + 4
15128  y = 24
15129  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
15130  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15131  y = y + 24
15132  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
15133  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15134  y = y + 24
15135  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
15136  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15137  y = y + 24
15138  txt = "Impedance Magnitude"
15139  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15140  y = y + 24
15141  if ImpedanceMagnitude >= 1000.0 or ImpedanceMagnitude <= -1000.0:
15142  txt = '{0:.2f}'.format(ImpedanceMagnitude/1000.0)
15143  txt = str(txt) + "K"
15144  elif ImpedanceMagnitude >= 100.0 or ImpedanceMagnitude <= -100.0:
15145  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
15146  elif ImpedanceMagnitude >= 10.0 or ImpedanceMagnitude <= -10.0:
15147  txt = ' {0:.2f} '.format(ImpedanceMagnitude)
15148  else:
15149  txt = ' {0:.3f} '.format(ImpedanceMagnitude)
15150  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15151  y = y + 24
15152  txt = "Impedance Angle"
15153  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15154  y = y + 24
15155  txt = ' {0:.1f} '.format(ImpedanceAngle)
15156  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15157  y = y + 24
15158  txt = "Impedance R series"
15159  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15160  y = y + 24
15161  if ImpedanceRseries >= 1000.0 or ImpedanceRseries <= -1000.0:
15162  txt = '{0:.2f}'.format(ImpedanceRseries/1000.0)
15163  txt = str(txt) + "K"
15164  elif ImpedanceRseries >= 100.0 or ImpedanceRseries <= -100.0:
15165  txt = ' {0:.1f} '.format(ImpedanceRseries)
15166  elif ImpedanceRseries >= 10.0 or ImpedanceRseries <= -10.0:
15167  txt = ' {0:.2f} '.format(ImpedanceRseries)
15168  else:
15169  txt = ' {0:.3f} '.format(ImpedanceRseries)
15170  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15171  y = y + 24
15172  txt = "Impedance X series"
15173  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15174  y = y + 24
15175  if ImpedanceXseries >= 1000.0 or ImpedanceXseries <= -1000.0:
15176  txt = '{0:.2f}'.format(ImpedanceXseries/1000.0)
15177  txt = str(txt) + "K"
15178  elif ImpedanceXseries >= 100.0 or ImpedanceXseries <= -100.0:
15179  txt = ' {0:.1f} '.format(ImpedanceXseries)
15180  elif ImpedanceXseries >= 10.0 or ImpedanceXseries <= -10.0:
15181  txt = ' {0:.2f} '.format(ImpedanceXseries)
15182  else:
15183  txt = ' {0:.3f} '.format(ImpedanceXseries)
15184  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15185 #
15186  Cseries = 0.0
15187  Cparallel = 0.0
15188  Lseries = 0.0
15189  Lparallel = 0.0
15190  Rparallel = 0.0
15191  if ImpedanceXseries < 0: # calculate series capacitance
15192  y = y + 24
15193  try:
15194  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
15195  except:
15196  Cseries = 0
15197  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
15198  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
15199  Cparallel = Cparallel * 1E6 # convert to micro Farads
15200  Rparallel = ImpedanceRseries * (1+Qseries**2)
15201  Cseries = Cseries * 1E6 # convert to micro Farads
15202  if DisplaySeries.get() == 0:
15203  txt = "Series Capacitance"
15204  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15205  y = y + 20
15206  if Cseries < 1:
15207  Ctext = Cseries * 1E3
15208  if Ctext < 1:
15209  Ctext = Ctext * 1E3
15210  CtextDis = Ctext + float(CapZeroEntry.get())
15211  txt = ' {0:.1f} '.format(CtextDis) + "pF"
15212  else:
15213  txt = ' {0:.3f} '.format(Ctext) + "nF"
15214  else:
15215  txt = ' {0:.3f} '.format(Cseries) + "uF"
15216  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15217  else:
15218  txt = "Parallel"
15219  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15220  y = y + 20
15221  if Cparallel < 1:
15222  Ctext = Cparallel * 1E3
15223  if Ctext < 1:
15224  Ctext = Ctext * 1E3
15225  txt = "Capacitance " + ' {0:.1f} '.format(Ctext) + "pF"
15226  else:
15227  txt = "Capacitance " + ' {0:.3f} '.format(Ctext) + "nF"
15228  else:
15229  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
15230  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15231  y = y + 20
15232  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15233  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15234  y = y + 20
15235  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
15236  txt = 'D = {0:.2f} '.format(dissp) + " %"
15237  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15238 
15239  elif ImpedanceXseries > 0: # calculate series inductance
15240  y = y + 24
15241  try:
15242  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
15243  except:
15244  Lseries = 0
15245  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
15246  if Qseries == 0.0: # Check if divide by zero
15247  Qseries = 0.00001
15248  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
15249  Lparallel = Lparallel * 1E3 # convert to millihenry
15250  Rparallel = ImpedanceRseries * (1+Qseries**2)
15251  Lseries = Lseries * 1E3 # in millihenry
15252  if DisplaySeries.get() == 0:
15253  txt = "Series Inductance"
15254  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15255  y = y + 22
15256  if Lseries < 1:
15257  Ltext = Lseries * 1E3
15258  txt = ' {0:.2f} '.format(Ltext) + "uH"
15259  else:
15260  txt = ' {0:.2f} '.format(Lseries) + "mH"
15261  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15262  else:
15263  txt = "Parallel"
15264  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15265  y = y + 20
15266  if Lparallel < 1:
15267  Ltext = Lparallel * 1E3
15268  txt = "Inductance " + ' {0:.2f} '.format(Ltext) + "uH"
15269  else:
15270  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
15271  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15272  y = y + 20
15273  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15274  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15275  y = y + 20
15276  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
15277  txt = 'Q = {0:.2f} '.format(qf)
15278  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15279  #
15280  if LoopNum.get() > 1:
15281  if NetworkScreenStatus.get() > 0:
15282  NSweepSeriesR.append(ImpedanceRseries)
15283  NSweepSeriesX.append(ImpedanceXseries)
15284  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
15285  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
15286  NSweepParallelR.append(Rparallel)
15287  NSweepParallelC.append(Cparallel) # in uF
15288  NSweepParallelL.append(Lparallel) # in mH
15289  NSweepSeriesC.append(Cseries) # in uF
15290  NSweepSeriesL.append(Lseries) # in mH
15291  # Start and stop frequency and trace mode
15292  Fmax = int(SAMPLErate * 0.45)
15293  txt = "0.0 to " + str(Fmax) + " Hz"
15294 
15295  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15296 
15297  x = X0LIA
15298  y = Y0TIA+GRHIA-13
15299  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15300  txt = " "
15301  if FreqTraceMode.get() == 1:
15302  txt ="Normal mode "
15303 
15304  if FreqTraceMode.get() == 2:
15305  txt = "Peak hold mode "
15306 
15307  if FreqTraceMode.get() == 3:
15308  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15309 
15310  if ZEROstuffing.get() > 0:
15311  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15312  # Runstatus and level information
15313  if (RUNstatus.get() == 0):
15314  txt = txt + " Stopped "
15315  else:
15316  txt = txt + " Running "
15317  y = Y0TIA+GRHIA
15318  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15319 #
15320 def IACaresize(event):
15321  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
15322 
15323  CANVASwidthIA = event.width - 4
15324  CANVASheightIA = event.height - 4
15325  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
15326  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
15327  UpdateIAAll()
15328 #
15329 # ================ Make IA Window ==========================
15331  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
15332  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode, AWG_2X
15333  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
15334  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev, CapZeroEntry
15335  global NetworkScreenStatus, IASweepSaved, IAGridType
15336  global FrameRefief, BorderSize
15337 
15338  if IAScreenStatus.get() == 0:
15339  IAScreenStatus.set(1)
15340  IADisp.set(1)
15341  IACheckBox()
15342  CutDC.set(1) # set to remove DC
15343  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
15344  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
15345  AWGAMode.set(0) # Set AWG A to SVMI
15346  AWGAShape.set(18) # Set Shape to Bode Sine
15347  ReMakeAWGwaves()
15348  if AWG_2X.get == 1:
15349  AWGBMode.set(0) # Set AWG B to SVMI
15350  else:
15351  AWGBMode.set(2) # Set AWG B to Hi-Z
15352  BAWGAModeLabel()
15353  BAWGBModeLabel()
15354  AWGSync.set(1) # Set AWGs to run sync
15355  iawindow = Toplevel()
15356  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
15357  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
15358  frame2iar = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15359  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
15360 
15361  frame2ia = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15362  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
15363 
15364  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
15365  IAca.bind("<Configure>", IACaresize)
15366  IAca.bind("<Return>", DoNothing)
15367  IAca.bind("<space>", onCanvasSpaceBar)
15368  IAca.pack(side=TOP, expand=YES, fill=BOTH)
15369 
15370  # menu buttons
15371  # right side drop down menu buttons
15372  dropmenu = Frame( frame2iar )
15373  dropmenu.pack(side=TOP)
15374  # File menu
15375  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15376  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
15377  IAFilemenu["menu"] = IAFilemenu.menu
15378  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15379  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15380  IAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15381  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
15382  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
15383  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
15384  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
15385  IAFilemenu.menu.add_command(label="Help", command=BHelp)
15386  IAFilemenu.pack(side=LEFT, anchor=W)
15387  #
15388  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15389  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
15390  IAOptionmenu["menu"] = IAOptionmenu.menu
15391  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15392  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15393  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15394  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
15395  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
15396  if DeBugMode == 1:
15397  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
15398  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
15399  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
15400  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
15401  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
15402  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
15403  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15404  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15405  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15406  IAOptionmenu.pack(side=LEFT, anchor=W)
15407  #
15408  rsemenu = Frame( frame2iar )
15409  rsemenu.pack(side=TOP)
15410  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
15411  rseb2.pack(side=RIGHT)
15412  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
15413  rseb3.pack(side=RIGHT)
15414  #
15415  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
15416  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
15417  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
15418  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15419  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15420  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15421  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15422  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15423  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15424  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15425  IAFFTwindmenu.pack(side=TOP)
15426  #
15427  smpmenu = Frame( frame2iar )
15428  smpmenu.pack(side=TOP)
15429  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15430  smpb1.pack(side=LEFT)
15431  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15432  smpb2.pack(side=LEFT)
15433  # Temp set source resistance to 1000
15434  rsystem = Frame( frame2iar )
15435  rsystem.pack(side=TOP)
15436  rsystemlab = Label(rsystem, text="Ext Res")
15437  rsystemlab.pack(side=LEFT, anchor=W)
15438  RsystemEntry = Entry(rsystem, width=7, cursor='double_arrow')
15439  RsystemEntry.bind('<Return>', onTextKey)
15440  RsystemEntry.bind('<MouseWheel>', onTextScroll)
15441  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15442  RsystemEntry.bind("<Button-5>", onTextScroll)
15443  RsystemEntry.bind('<Key>', onTextKey)
15444  RsystemEntry.pack(side=LEFT, anchor=W)
15445  RsystemEntry.delete(0,"end")
15446  RsystemEntry.insert(4,1000)
15447  # Res Scale Spinbox
15448  ressb = Frame( frame2iar )
15449  ressb.pack(side=TOP)
15450  reslab = Label(ressb, text="Ohms/div ")
15451  reslab.pack(side=LEFT)
15452  ResScale = Spinbox(ressb, width=7, cursor='double_arrow', values=ResScalediv)
15453  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
15454  ResScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15455  ResScale.bind("<Button-5>", onSpinBoxScroll)
15456  ResScale.pack(side=LEFT)
15457  ResScale.delete(0,"end")
15458  ResScale.insert(0,500)
15459  #
15460  GainCor = Frame( frame2iar )
15461  GainCor.pack(side=TOP)
15462  GainCorlab = Label(GainCor, text="Gain Cor dB")
15463  GainCorlab.pack(side=LEFT, anchor=W)
15464  GainCorEntry = Entry(GainCor, width=7, cursor='double_arrow')
15465  GainCorEntry.bind('<Return>', onTextKey)
15466  GainCorEntry.bind('<MouseWheel>', onTextScroll)
15467  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15468  GainCorEntry.bind("<Button-5>", onTextScroll)
15469  GainCorEntry.bind('<Key>', onTextKey)
15470  GainCorEntry.pack(side=LEFT, anchor=W)
15471  GainCorEntry.delete(0,"end")
15472  GainCorEntry.insert(4,0.0)
15473  #
15474  PhaseCor = Frame( frame2iar )
15475  PhaseCor.pack(side=TOP)
15476  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
15477  PhaseCorlab.pack(side=LEFT, anchor=W)
15478  PhaseCorEntry = Entry(PhaseCor, width=7, cursor='double_arrow')
15479  PhaseCorEntry.bind('<Return>', onTextKey)
15480  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
15481  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15482  PhaseCorEntry.bind("<Button-5>", onTextScroll)
15483  PhaseCorEntry.bind('<Key>', onTextKey)
15484  PhaseCorEntry.pack(side=LEFT, anchor=W)
15485  PhaseCorEntry.delete(0,"end")
15486  PhaseCorEntry.insert(4,0.0)
15487  #
15488  capofflab = Label(frame2iar, text="Capacitance Offset")
15489  capofflab.pack(side=TOP)
15490  CapZero = Frame( frame2iar )
15491  CapZero.pack(side=TOP)
15492  CapZerobutton = Button(CapZero, text="Zero", style="W4.TButton", command=IACapZero)
15493  CapZerobutton.pack(side=LEFT, anchor=W)
15494  CapResetbutton = Button(CapZero, text="Reset", style="W5.TButton", command=IACapReset)
15495  CapResetbutton.pack(side=LEFT, anchor=W)
15496  CapZeroEntry = Entry(CapZero, width=6, cursor='double_arrow')
15497  CapZeroEntry.bind('<Return>', onTextKey)
15498  CapZeroEntry.bind('<MouseWheel>', onTextScroll)
15499  CapZeroEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15500  CapZeroEntry.bind("<Button-5>", onTextScroll)
15501  CapZeroEntry.bind('<Key>', onTextKey)
15502  CapZeroEntry.pack(side=LEFT, anchor=W)
15503  CapZeroEntry.delete(0,"end")
15504  CapZeroEntry.insert(4,0.0)
15505  #
15506  srclab = Label(frame2iar, text="Source")
15507  srclab.pack(side=TOP)
15508  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
15509  extsrc1.pack(side=TOP)
15510  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
15511  extsrc2.pack(side=TOP)
15512  #
15513  gridmenu = Frame( frame2iar )
15514  gridmenu.pack(side=TOP)
15515  iagrid1= Radiobutton(frame2iar, text="Polar Grid", variable=IAGridType, value=0) #, command=IAGridSet)
15516  iagrid1.pack(side=TOP)
15517  iagrid2 = Radiobutton(frame2iar, text="Rect Grid", variable=IAGridType, value=1) #, command=IAGridSet)
15518  iagrid2.pack(side=TOP)
15519  #
15520  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
15521  dismiss1button.pack(side=TOP)
15522  # add ADI logo
15523  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
15524  ADI1.pack(side=TOP)
15525 #
15527  global iawindow, IAScreenStatus, IAca, IADisp
15528 
15529  IAScreenStatus.set(0)
15530  IADisp.set(0)
15531  IACheckBox()
15532  iawindow.destroy()
15533 #
15535  global TIAMline, TIAMRline, IASweepSaved
15536 
15537  if IASweepSaved.get() > 0:
15538  TIAMRline = TIAMline
15539 #
15541  global Cseries, CapZeroEntry
15542 
15543  Ctext = ' {0:.1f} '.format(-Cseries * 1E6)
15544  CapZeroEntry.delete(0,"end")
15545  CapZeroEntry.insert(6,Ctext)
15546 #
15548  global CapZeroEntry
15549 
15550  CapZeroEntry.delete(0,"end")
15551  CapZeroEntry.insert(4,0.0)
15552 #
15554  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
15555  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
15556  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
15557  global NetworkScreenStatus, NqPSweepSaved
15558  global FrameRefief, BorderSize
15559 
15560  if NqPScreenStatus.get() == 0:
15561  NqPScreenStatus.set(1)
15562  NqPDisp.set(1)
15563  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
15564  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
15565  nqpwindow = Toplevel()
15566  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
15567  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
15568 
15569  frame2nqp = Frame(nqpwindow, borderwidth=BorderSize, relief=FrameRefief)
15570  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
15571 
15572  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
15573  NqPca.bind("<Configure>", NqPCaresize)
15574  NqPca.bind("<Return>", DoNothing)
15575  NqPca.bind("<space>", onCanvasSpaceBar)
15576  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
15577 #
15579  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
15580 
15581  NqPScreenStatus.set(0)
15582  NqPDisp.set(0)
15583  nqpwindow.destroy()
15584 #
15585 def NqPCaresize(event):
15586  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
15587 
15588  CANVASwidthNqP = event.width - 4
15589  CANVASheightNqP = event.height - 4
15590  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
15591  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
15592  UpdateNqPAll()
15593 
15596  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
15597  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15598  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
15599  global Vdiv, FBins, FStep
15600  global FontSize
15601 
15602  # Delete all items on the canvas
15603  NqPca.delete(ALL) # remove all items
15604  SmoothBool = SmoothCurvesBP.get()
15605  # Draw circular grid lines
15606  i = 1
15607  xcenter = GRWNqP/2
15608  ycenter = GRHNqP/2
15609  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
15610  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
15611  TRadius = Radius * Vdiv.get() # 5
15612  x1 = X0LNqP
15613  x2 = X0LNqP + GRWNqP
15614  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
15615  while (i <= Vdiv.get()):
15616  x0 = xcenter - ( i * Radius )
15617  x1 = xcenter + ( i * Radius )
15618  y0 = ycenter - ( i * Radius )
15619  y1 = ycenter + ( i * Radius )
15620  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15621  NqPca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
15622  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
15623  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15624  #
15625  i = i + 1
15626  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
15627  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
15628  RAngle = math.radians(45)
15629  y = TRadius*math.sin(RAngle)
15630  x = TRadius*math.cos(RAngle)
15631  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15632  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15633  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
15634  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15635  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
15636  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
15637  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
15638 # Draw traces
15639  NqPline = []
15640  if len(FSweepAdB) > 4:
15641  for index in range(len(FSweepAdB)): # while n < len(FStep):
15642  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15643  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15644  else:
15645  F = FBins[int(FStep[0])]
15646  # Mag value
15647  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15648  dbB = 10 * math.log10(float(FSweepBdB[index]))
15649  if ShowMathBP.get() == 1:
15650  MdB = dbA - dbB
15651  elif ShowMathBP.get() == 2:
15652  MdB = dbB - dbA
15653  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
15654  # Phase Value
15655  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15656  if RelPhase > 180:
15657  RelPhase = RelPhase - 360
15658  elif RelPhase < -180:
15659  RelPhase = RelPhase + 360
15660  if Two_X_Sample.get() == 0:
15661  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15662  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15663  else:
15664  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
15665  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
15666  if y1 > 1500:
15667  y1 = xright
15668  elif y1 < -500:
15669  y1 = ycenter - xright
15670  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
15671  if x1 > 1500:
15672  x1 = xright
15673  elif x1 < -500:
15674  x1 = xcenter - xright
15675  NqPline.append(x1)
15676  NqPline.append(y1)
15677  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15678 #
15680  global NiCScreenStatus, NiCDisp
15681  global nicwindow, NiCca, logo, SWRev
15682  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
15683  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
15684  global NetworkScreenStatus, NiCSweepSaved
15685  global FrameRefief, BorderSize
15686 
15687  if NiCScreenStatus.get() == 0:
15688  NiCScreenStatus.set(1)
15689  NiCDisp.set(1)
15690  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
15691  CANVASheightNic = GRHNiC + 60 # The canvas height
15692  nicwindow = Toplevel()
15693  nicwindow.title("Nichols Plot " + SWRev + RevDate)
15694  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
15695 
15696  frame2nic = Frame(nicwindow, borderwidth=BorderSize, relief=FrameRefief)
15697  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
15698 
15699  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
15700  NiCca.bind("<Configure>", NiCCaresize)
15701  NiCca.bind("<Return>", DoNothing)
15702  NiCca.bind("<space>", onCanvasSpaceBar)
15703  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
15704 #
15706  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
15707 
15708  NiCScreenStatus.set(0)
15709  NiCDisp.set(0)
15710  nicwindow.destroy()
15711 #
15712 def NiCCaresize(event):
15713  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
15714 
15715  CANVASwidthNic = event.width - 4
15716  CANVASheightNic = event.height - 4
15717  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
15718  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
15719  UpdateNiCAll()
15720 
15723  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
15724  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
15725  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15726  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
15727  global FontSize
15728 
15729  Ymin = Y0TNiC # Minimum position of XY grid (top)
15730  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
15731  Xmin = X0LNiC # Minimum position of XY grid (left)
15732  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
15733  try:
15734  Phasecenter = int(PhCenBodeEntry.get())
15735  RelPhaseCenter.set(Phasecenter)
15736  except:
15737  PhCenBodeEntry.delete(0,"end")
15738  PhCenBodeEntry.insert(0,0)
15739  RelPhaseCenter.set(0)
15740  Phasecenter = 0
15741  # Delete all items on the screen
15742  MarkerNum = 0
15743  SmoothBool = SmoothCurvesBP.get()
15744  NiCca.delete(ALL) # remove all items
15745  # Draw horizontal grid lines Rel Gain Magnitude
15746  i = 0
15747  x1 = X0LNiC
15748  x2 = X0TNiC = X0LNiC + GRWNiC
15749  mg_siz = GRWNiC/10.0
15750  mg_inc = mg_siz/5.0
15751  DegPerDiv = 360 / 10
15752  while (i < Vdiv.get()+1):
15753  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15754  y = Y0TNiC + i * GRHNiC/Vdiv.get()
15755  Dline = [x1,y,x2,y]
15756  if dBaxis_value == 0:
15757  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
15758  k = 0
15759  while (k < 10):
15760  l = 1
15761  while (l < 5): # add tick marks
15762  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
15763  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15764  l = l + 1
15765  k = k + 1
15766  else:
15767  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15768  dBaxis_label = str(dBaxis_value)
15769  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15770 
15771  i = i + 1
15772  # Draw vertical grid lines (phase -180 to 180 10 div)
15773  i = 0
15774  y1 = Y0TNiC
15775  y2 = Y0TNiC + GRHNiC
15776  mg_siz = GRHNiC/10.0
15777  mg_inc = mg_siz/5.0
15778  #
15779  while (i < 11):
15780  x = X0LNiC + i * GRWNiC/10.0
15781  Dline = [x,y1,x,y2]
15782  axis_value = Phasecenter - 180 + (i * DegPerDiv)
15783  axis_label = str(axis_value)
15784  if ( axis_value == 0):
15785  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
15786  k = 0
15787  while (k < 10):
15788  l = 1
15789  while (l < 5): # add tick marks
15790  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
15791  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15792  l = l + 1
15793  k = k + 1
15794  else:
15795  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15796  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
15797  i = i + 1
15798  # Draw traces
15799  # Vertical conversion factors (level dBs) and border limits
15800  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15801  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15802  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
15803  Xp = float(X0LNiC) + Xphconv * 180.0
15804  x1 = X0LNiC + 14
15805  # Horizontal conversion factors (phase deg) and border limits
15806  NiCline = []
15807  if len(FSweepAdB) > 4:
15808  index = 0
15809  for index in range(len(FSweepAdB)): # while n < len(FStep):
15810  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15811  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15812  else:
15813  F = FBins[int(FStep[0])]
15814  # Mag value
15815  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15816  dbB = 10 * math.log10(float(FSweepBdB[index]))
15817  if ShowMathBP.get() == 1:
15818  MdB = dbA - dbB
15819  elif ShowMathBP.get() == 2:
15820  MdB = dbB - dbA
15821  yb = Yc - Yconv * MdB
15822  if (yb < Ymin):
15823  yb = Ymin
15824  if (yb > Ymax):
15825  yb = Ymax
15826  # Phase Value
15827  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15828  RelPhase = RelPhase - Phasecenter
15829  if RelPhase > 180:
15830  RelPhase = RelPhase - 360
15831  elif RelPhase < -180:
15832  RelPhase = RelPhase + 360
15833  if Two_X_Sample.get() == 0:
15834  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15835  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15836  else:
15837  RelPhase = RelPhase # - PhaseOffset2x
15838  xa = Xp + Xphconv * RelPhase
15839  if (xa < Xmin):
15840  xa = Ymin
15841  if (xa > Xmax):
15842  xa = Xmax
15843  NiCline.append(int(xa + 0.5))
15844  NiCline.append(int(yb + 0.5))
15845  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15846 #
15847 def UpdateNqPAll(): # Update Data, trace and screen
15848  global FFTBuffA, FFTBuffB
15849  global SMPfft
15850 
15851  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15852  return
15853  #MakeNqPTrace() # Update the traces
15854  UpdateNqPScreen() # Update the screen
15855 
15856 def UpdateNqPTrace(): # Update trace and screen
15857 
15858  #MakeNqPTrace() # Update traces
15859  UpdateNqPScreen() # Update the screen
15860 
15861 def UpdateNqPScreen(): # Update screen with trace and text
15862 
15863  MakeNqPScreen() # Update the screen
15864  root.update() # Activate updated screens
15865 #
15866 def UpdateNiCAll(): # Update Data, trace and screen
15867  global FFTBuffA, FFTBuffB
15868  global SMPfft
15869 
15870  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15871  return
15872  #MakeNiCTrace() # Update the traces
15873  UpdateNiCScreen() # Update the screen
15874 
15875 def UpdateNiCTrace(): # Update trace and screen
15876 
15877  #MakeNiCTrace() # Update traces
15878  UpdateNiCScreen() # Update the screen
15879 
15880 def UpdateNiCScreen(): # Update screen with trace and text
15881 
15882  MakeNiCScreen() # Update the screen
15883  root.update() # Activate updated screens
15884 #
15885 #
15886 def VAtoggle():
15887  global vat_btn
15888 
15889  if vat_btn.config('text')[-1] == 'ON':
15890  vat_btn.config(text='OFF', style="Stop.TButton")
15891  else:
15892  vat_btn.config(text='ON', style="Run.TButton")
15893 #
15895  global vabt_btn
15896 
15897  if vabt_btn.config('text')[-1] == 'ON':
15898  vabt_btn.config(text='OFF', style="Stop.TButton")
15899  else:
15900  vabt_btn.config(text='ON', style="Run.TButton")
15901 #
15902 def VBtoggle():
15903  global vbt_btn
15904 
15905  if vbt_btn.config('text')[-1] == 'ON':
15906  vbt_btn.config(text='OFF', style="Stop.TButton")
15907  else:
15908  vbt_btn.config(text='ON', style="Run.TButton")
15909 #
15910 def IAtoggle():
15911  global iat_btn
15912 
15913  if iat_btn.config('text')[-1] == 'ON':
15914  iat_btn.config(text='OFF', style="Stop.TButton")
15915  else:
15916  iat_btn.config(text='ON', style="Run.TButton")
15917 #
15918 def IBtoggle():
15919  global ibt_btn
15920 
15921  if ibt_btn.config('text')[-1] == 'ON':
15922  ibt_btn.config(text='OFF', style="Stop.TButton")
15923  else:
15924  ibt_btn.config(text='ON', style="Run.TButton")
15925 #
15926 # ================ Make Phase Ana Window ==========================
15928  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
15929  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
15930  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
15931  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
15932  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
15933  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
15934  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
15935  global FrameRefief, BorderSize
15936 
15937  if PhAScreenStatus.get() == 0:
15938  PhAScreenStatus.set(1)
15939  PhADisp.set(1)
15940  PhACheckBox()
15941  CutDC.set(1) # set to remove DC
15942  CANVASwidthPhA = 170 + GRWPhA + 2 * X0LPhA # The canvas width
15943  CANVASheightPhA = GRHPhA + Y0TPhA + 10 # The canvas height
15944  phawindow = Toplevel()
15945  phawindow.title("Phase Analyzer " + SWRev + RevDate)
15946  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
15947  frame2phar = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15948  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
15949 
15950  frame2pha = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15951  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
15952 
15953  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
15954  PhAca.bind("<Configure>", PhACaresize)
15955  PhAca.bind("<Return>", DoNothing)
15956  PhAca.bind("<space>", onCanvasSpaceBar)
15957  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
15958 
15959  if MuxScreenStatus.get() == 0:
15960  RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
15961  else:
15962  RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
15963  # menu buttons
15964  # right side drop down menu buttons
15965  dropmenu = Frame( frame2phar )
15966  dropmenu.pack(side=TOP)
15967  # File menu
15968  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15969  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
15970  PhAFilemenu["menu"] = PhAFilemenu.menu
15971  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15972  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15973  PhAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15974  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
15975  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
15976  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
15977  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
15978  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
15979  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
15980  PhAFilemenu.pack(side=LEFT, anchor=W)
15981  #
15982  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15983  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
15984  PhAOptionmenu["menu"] = PhAOptionmenu.menu
15985  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15986  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15987  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15988 
15989  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15990  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15991  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15992  PhAOptionmenu.pack(side=LEFT, anchor=W)
15993  #
15994  rsphmenu = Frame( frame2phar )
15995  rsphmenu.pack(side=TOP)
15996  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
15997  rsphb2.pack(side=RIGHT)
15998  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
15999  rsphb3.pack(side=RIGHT)
16000  #
16001  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
16002  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
16003  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
16004  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
16005  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
16006  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
16007  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
16008  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
16009  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
16010  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
16011  PhAFFTwindmenu.pack(side=TOP)
16012  #
16013  FFTwindow.set(6) # default to Flat top window (6)
16014  #
16015  smphmenu = Frame( frame2phar )
16016  smphmenu.pack(side=TOP)
16017  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
16018  smphb1.pack(side=LEFT)
16019  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
16020  smphb2.pack(side=LEFT)
16021  #
16022  refph = Frame( frame2phar )
16023  refph.pack(side=TOP)
16024  refphlab = Label(refph, text="Ref Phase")
16025  refphlab.pack(side=LEFT, anchor=W)
16026  RefphEntry = Spinbox(refph, width=5, cursor='double_arrow', values=RefPhase)
16027  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
16028  RefphEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16029  RefphEntry.bind("<Button-5>", onSpinBoxScroll)
16030  RefphEntry.pack(side=LEFT, anchor=W)
16031  RefphEntry.delete(0,"end")
16032  RefphEntry.insert(0,"CA-V")
16033  vatb = Frame( frame2phar )
16034  vatb.pack(side=TOP)
16035  vatblab = Label(vatb, text="CA-V ")
16036  vatblab.pack(side=LEFT)
16037  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
16038  vat_btn.pack(side=LEFT)
16039  vbtb = Frame( frame2phar )
16040  vbtb.pack(side=TOP)
16041  if MuxScreenStatus.get() == 0:
16042  #RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
16043  vbtblab = Label(vbtb, text="CB-V ")
16044  vbtblab.pack(side=LEFT)
16045  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
16046  vbt_btn.pack(side=LEFT)
16047  vabtb = Frame( frame2phar )
16048  vabtb.pack(side=TOP)
16049  vabtblab = Label(vabtb, text="CA-B V ")
16050  vabtblab.pack(side=LEFT)
16051  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
16052  vabt_btn.pack(side=LEFT)
16053  else:
16054  #RefphEntry.configure(state=DISABLED)
16055  #RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
16056  amuxlab = Label(frame2phar, text="Analog Mux In")
16057  amuxlab.pack(side=TOP)
16058  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
16059  phbt1.pack(side=TOP)
16060  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
16061  phbt2.pack(side=TOP)
16062  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
16063  phbt3.pack(side=TOP)
16064  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
16065  phbt4.pack(side=TOP)
16066 #
16067  # Voltage Scale Spinbox
16068  vssb = Frame( frame2phar )
16069  vssb.pack(side=TOP)
16070  vslab = Label(vssb, text="Volts/div ")
16071  vslab.pack(side=LEFT)
16072  VScale = Spinbox(vssb, width=7, cursor='double_arrow', values=CHvpdiv)
16073  VScale.bind('<MouseWheel>', onSpinBoxScroll)
16074  VScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16075  VScale.bind("<Button-5>", onSpinBoxScroll)
16076  VScale.pack(side=LEFT)
16077  VScale.delete(0,"end")
16078  VScale.insert(0,0.5)
16079  #
16080  iatb = Frame( frame2phar )
16081  iatb.pack(side=TOP)
16082  iatblab = Label(iatb, text="CA-I ")
16083  iatblab.pack(side=LEFT)
16084  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
16085  iat_btn.pack(side=LEFT)
16086  ibtb = Frame( frame2phar )
16087  ibtb.pack(side=TOP)
16088  ibtblab = Label(ibtb, text="CB-I ")
16089  ibtblab.pack(side=LEFT)
16090  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
16091  ibt_btn.pack(side=LEFT)
16092  # Current Scale Spinbox
16093  issb = Frame( frame2phar )
16094  issb.pack(side=TOP)
16095  islab = Label(issb, text="mA/div ")
16096  islab.pack(side=LEFT)
16097  IScale = Spinbox(issb, width=7, cursor='double_arrow', values=CHipdiv)
16098  IScale.bind('<MouseWheel>', onSpinBoxScroll)
16099  IScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16100  IScale.bind("<Button-5>", onSpinBoxScroll)
16101  IScale.pack(side=LEFT)
16102  IScale.delete(0,"end")
16103  IScale.insert(0,10.0)
16104 
16105  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
16106  dismiss1button.pack(side=TOP)
16107  # add ADI logo
16108  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16109  ADI1.pack(side=TOP)
16110 #
16111 # Destroy Phase Analizer window
16113  global phawindow, PhAScreenStatus, PhAca, PhADisp
16114 
16115  PhAScreenStatus.set(0)
16116  PhADisp.set(0)
16117  PhACheckBox()
16118  phawindow.destroy()
16119 #
16120 # Resize Phase Analizer window
16121 def PhACaresize(event):
16122  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
16123 
16124  CANVASwidthPhA = event.width - 4
16125  CANVASheightPhA = event.height - 4
16126  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
16127  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
16128  UpdatePhAAll()
16129 #
16130 def UpdatePhAAll(): # Update Data, trace and screen
16131 
16132  MakePhATrace() # Update the traces
16133  UpdatePhAScreen() # Update the screen
16134 
16135 def UpdatePhATrace(): # Update trace and screen
16136  MakePhATrace() # Update traces
16137  UpdatePhAScreen() # Update the screen
16138 
16139 def UpdatePhAScreen(): # Update screen with trace and text
16140  MakePhAScreen() # Update the screen
16141  root.update() # Activate updated screens
16142 #
16143 # Place holder
16144 def MakePhATrace(): # Update the grid and trace
16145  global VAresult, VBresult, IAresult, IBresult, VABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB
16146  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
16147  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB
16148  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16149  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16150  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB
16151  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16152  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16153  global GRHPhA # Screenheight
16154  global GRWPhA # Screenwidth
16155  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
16156  global STARTsample, STOPsample, LoopNum, FSweepMode
16157  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan, ChopMuxMode
16158  global Vdiv # Number of vertical divisions
16159  global X0LPhA # Left top X value
16160  global Y0TPhA # Left top Y value
16161 
16162  # Set the TRACEsize variable
16163  if len(VAresult) < 32:
16164  return
16165  TRACEsize = len(VAresult) # Set the trace length
16166  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
16167  # Horizontal conversion factors (frequency Hz) and border limits
16168  STARTsample = 0 # First sample in FFTresult[] that is used
16169  STARTsample = int(math.ceil(STARTsample)) # First within screen range
16170  if Two_X_Sample.get() == 0:
16171  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
16172  else:
16173  STOPsample = 90000 / Fsample
16174  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
16175 #
16176 
16177  MAXsample = TRACEsize # Just an out of range check
16178  if STARTsample > (MAXsample - 1):
16179  STARTsample = MAXsample - 1
16180 
16181  if STOPsample > MAXsample:
16182  STOPsample = MAXsample
16183 
16184  n = STARTsample +1
16185  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = 0.0
16186  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = F = n * Fsample
16187  PeakphaseVA = PhaseVA[n]
16188  if MuxScreenStatus.get() == 0:
16189  PeakphaseVB = PhaseVB[n]
16190  else:
16191  PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
16192  PeakphaseIA = PhaseIA[n]
16193  PeakphaseIB = PhaseIB[n]
16194  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
16195  PeakSampleVMA = PeakSampleVMB = PeakSampleVMC = PeakSampleVMD = n
16196  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16197  PeakVMA = 0
16198  PeakphaseVMA = PhaseVMA[n]
16199  PeakSampleVMA = 0
16200  PeakfreqVMA = PeakfreqVA
16201  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16202  PeakVMB = 0
16203  PeakphaseVMB = PhaseVMB[n]
16204  PeakSampleVMB = 0
16205  PeakfreqVMB = PeakfreqVA
16206  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16207  PeakVMC = 0
16208  PeakphaseVMC = PhaseVMC[n]
16209  PeakSampleVMC = 0
16210  PeakfreqVMC = PeakfreqVA
16211  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16212  PeakVMD = 0
16213  PeakphaseVMD = PhaseVMD[n]
16214  PeakSampleVMD = 0
16215  PeakfreqVMD = PeakfreqVA
16216 
16217  while n <= STOPsample: # search for peaks
16218  F = n * Fsample
16219  try:
16220  VA = float(VAresult[n]) #
16221  except:
16222  VA = 0.0
16223  if VA > PeakVA:
16224  PeakVA = VA
16225  PeakfreqVA = F
16226  PeakphaseVA = PhaseVA[n]
16227  PeakSampleVA = n
16228 
16229  if MuxScreenStatus.get() == 0:
16230  try:
16231  VAB = float(VABresult[n]) #
16232  except:
16233  VAB = 0.0
16234  if VAB > PeakVAB:
16235  PeakVAB = VAB
16236  PeakfreqVAB = F
16237  PeakphaseVAB = PhaseVAB[n]
16238  PeakSampleVAB = n
16239 
16240  try:
16241  VB = float(VBresult[n]) #
16242  except:
16243  VB = 0.0
16244  if VB > PeakVB:
16245  PeakVB = VB
16246  PeakfreqVB = F
16247  PeakphaseVB = PhaseVB[n]
16248  PeakSampleVB = n
16249  else:
16250  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16251  try:
16252  VMA = float(VMAresult[n]) #
16253  except:
16254  VMA = 0.0
16255  if VMA > PeakVMA:
16256  PeakVMA = VMA
16257  PeakfreqVMA = F
16258  PeakphaseVMA = PhaseVMA[n]
16259  PeakSampleVMA = n
16260  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16261  try:
16262  VMB = float(VMBresult[n]) #
16263  except:
16264  VMB = 0.0
16265  if VMB > PeakVMB:
16266  PeakVMB = VMB
16267  PeakfreqVMB = F
16268  PeakphaseVMB = PhaseVMB[n]
16269  PeakSampleVMB = n
16270  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16271  try:
16272  VMC = float(VMCresult[n]) #
16273  except:
16274  VMC = 0.0
16275  if VMC > PeakVMC:
16276  PeakVMC = VMC
16277  PeakfreqVMC = F
16278  PeakphaseVMC = PhaseVMC[n]
16279  PeakSampleVMC = n
16280  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16281  try:
16282  VMD = float(VMDresult[n]) #
16283  except:
16284  VMD = 0.0
16285  if VMD > PeakVMD:
16286  PeakVMD = VMD
16287  PeakfreqVMD = F
16288  PeakphaseVMD = PhaseVMD[n]
16289  PeakSampleVMD = n
16290  try:
16291  IA = float(IAresult[n]) #
16292  except:
16293  IA = 0.0
16294  if IA > PeakIA:
16295  PeakIA = IA
16296  PeakfreqIA = F
16297  PeakphaseIA = PhaseIA[n]
16298  PeakSampleIA = n
16299 
16300  try:
16301  IB = float(IBresult[n]) #
16302  except:
16303  IB = 0.0
16304  if IB > PeakIB:
16305  PeakIB = IB
16306  PeakfreqIB = F
16307  PeakphaseIB = PhaseIB[n]
16308  PeakSampleIB = n
16309 
16310  n = n + 1
16311  # Check to see that V, Vnux and I peaks are in same frequency bin?
16312  if PeakSampleVA != PeakSampleIA:
16313  PeakphaseIA = PhaseIA[PeakSampleVA]
16314  PeakIA = IAresult[PeakSampleVA]
16315  if PeakSampleVB != PeakSampleIB and MuxScreenStatus.get() == 0:
16316  PeakphaseIB = PhaseIB[PeakSampleVB]
16317  PeakIB = IBresult[PeakSampleVB]
16318  if MuxScreenStatus.get() > 0:
16319  if PeakSampleVA != PeakSampleVMA:
16320  try:
16321  PeakphaseVMA = PhaseVMA[PeakSampleVA]
16322  PeakVMA = float(VMAresult[PeakSampleVA])
16323  except:
16324  donothing()
16325  if PeakSampleVA != PeakSampleVMB:
16326  try:
16327  PeakphaseVMB = PhaseVMB[PeakSampleVA]
16328  PeakVMB = float(VMBresult[PeakSampleVA])
16329  except:
16330  donothing()
16331  if PeakSampleVA != PeakSampleVMC:
16332  try:
16333  PeakphaseVMC = PhaseVMC[PeakSampleVA]
16334  PeakVMC = float(VMCresult[PeakSampleVA])
16335  except:
16336  donothing()
16337  if PeakSampleVA != PeakSampleVMD:
16338  try:
16339  PeakphaseVMD = PhaseVMD[PeakSampleVA]
16340  PeakVMD = float(VMDresult[PeakSampleVA])
16341  except:
16342  donothing()
16343 #
16344 # Draw the Phase Analyzer screen
16345 def MakePhAScreen(): # Update the screen with traces and text
16346  global PeakVA, PeakVB, PeakIA, PeakIB
16347  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16348  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB
16349  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16350  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16351  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16352  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16353  global CMAphase, CMBphase, CMCphase, CMDphase
16354  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
16355  global COLORsignalband, COLORtext, COLORgrid # The colors
16356  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
16357  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
16358  global X0LPhA # Left top X value
16359  global Y0TPhA # Left top Y value
16360  global GRWPhA # Screenwidth
16361  global GRHPhA # Screenheight
16362  global FontSize, MuxScreenStatus, MuxChan, Mulx, ChopMuxMode
16363  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
16364  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
16365  global SMPfft # number of FFT samples
16366  global TRACEaverage # Number of traces for averageing
16367  global FreqTraceMode # 1 normal 2 max 3 average
16368  global Vdiv, VScale, IScale # Number of vertical divisions
16369  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
16370  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16371  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
16372  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
16373  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
16374  global InOffA, InGainA, InOffB, InGainB
16375  global CurOffA, CurOffB, CurGainA, CurGainB
16376  # Analog Mux channel measurement variables
16377  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
16378  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
16379  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
16380  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
16381  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
16382  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
16383  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
16384  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
16385  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
16386  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
16387  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
16388  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
16389 
16390  # Delete all items on the screen
16391  PhAca.delete(ALL) # remove all items
16392  # SmoothBool = SmoothCurvesBP.get()
16393  # Draw circular grid lines
16394  i = 1
16395  xcenter = GRWPhA/2
16396  ycenter = (GRHPhA/2) + 14
16397  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
16398  VoltsperPixel = float(VScale.get())/Radius
16399  mAperPixel = float(IScale.get())/Radius
16400  TRadius = Radius * Vdiv.get() # 5
16401  x1 = X0LPhA
16402  x2 = X0LPhA + GRWPhA
16403  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
16404  while (i <= Vdiv.get()):
16405  x0 = xcenter - ( i * Radius )
16406  x1 = xcenter + ( i * Radius )
16407  y0 = ycenter - ( i * Radius )
16408  y1 = ycenter + ( i * Radius )
16409  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
16410  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
16411  TOffset = xright+(4*FontSize)
16412  PhAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
16413  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
16414  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
16415  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
16416  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
16417  #
16418  i = i + 1
16419  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
16420  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
16421  RAngle = math.radians(45)
16422  y = TRadius*math.sin(RAngle)
16423  x = TRadius*math.cos(RAngle)
16424  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16425  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16426  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
16427  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16428  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
16429  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
16430  YBot = y1
16431  # calculate phase error due half sample period offset 0.0018
16432  if Two_X_Sample.get() == 0:
16433  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
16434  PhErr = 0.001675 * PeakfreqVA
16435  PhErrMA = PhErr
16436  PhErrMB = PhErr
16437  PhErrMC = PhErr
16438  PhErrMD = PhErr
16439  else:
16440  PhErr = 0.0
16441  PhErrMA = PhErr
16442  PhErrMB = PhErr
16443  PhErrMC = PhErr
16444  PhErrMD = PhErr
16445  else:
16446  PhErr = 0.0
16447  PhErrMA = PhErr
16448  PhErrMB = PhErr
16449  PhErrMC = PhErr
16450  PhErrMD = PhErr
16451  if ChopMuxMode.get() > 0:
16452  PhErrMB = 0.0072 * PeakfreqVMB
16453  PhErrMA = 0.0016 * PeakfreqVMA #
16454  PhErrMD = 0.0054 * PeakfreqVMD
16455  PhErrMC = 0.0016 * PeakfreqVMC #
16456 # Draw traces
16457 #
16458  if RefphEntry.get() == "CA-V":
16459  CAVphase = 0.0
16460  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
16461  CAIphase = PeakphaseVA - PeakphaseIA
16462  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16463  CABVphase = PeakphaseVA - PeakphaseVAB
16464  elif RefphEntry.get() == "CB-V":
16465  CBVphase = 0.0
16466  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
16467  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
16468  CBIphase = PeakphaseVB - PeakphaseIB
16469  CABVphase = PeakphaseVB - PeakphaseVAB
16470  elif RefphEntry.get() == "CA-I":
16471  CAIphase = 0.0
16472  CAVphase = PeakphaseIA - PeakphaseVA
16473  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
16474  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
16475  CABVphase = PeakphaseIA - PeakphaseVAB
16476  elif RefphEntry.get() == "CB-I":
16477  CBIphase = 0.0
16478  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
16479  CBVphase = PeakphaseIB - PeakphaseVB
16480  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
16481  CABVphase = PeakphaseIB - PeakphaseVAB
16482  #
16483  if MuxScreenStatus.get() > 0:
16484  CBVphase = 0.0
16485  if RefphEntry.get() == "CA-V":
16486  CAVphase = 0.0
16487  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
16488  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
16489  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
16490  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
16491  CAIphase = PeakphaseVA - PeakphaseIA
16492  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16493  elif RefphEntry.get() == "CB-A":
16494  CMAphase = 0.0
16495  CAVphase = PeakphaseVMA - PeakphaseVA + PhErr
16496  CMBphase = PeakphaseVMA - PeakphaseVMB - PhErrMB
16497  CMCphase = PeakphaseVMA - PeakphaseVMC + PhErrMC
16498  CMDphase = PeakphaseVMA - PeakphaseVMD - PhErrMD
16499  CAIphase = PeakphaseVMA - PeakphaseIA
16500  CBIphase = PeakphaseVMA - PeakphaseIB + PhErr
16501  elif RefphEntry.get() == "CB-B":
16502  CMBphase = 0.0
16503  CAVphase = PeakphaseVMB - PeakphaseVA + PhErr
16504  CMAphase = PeakphaseVMB - PeakphaseVMA + PhErrMD
16505  CMCphase = PeakphaseVMB - PeakphaseVMC + PhErrMB
16506  CMDphase = PeakphaseVMB - PeakphaseVMD + PhErrMC
16507  CAIphase = PeakphaseVMB - PeakphaseIA
16508  CBIphase = PeakphaseVMB - PeakphaseIB + PhErr
16509  elif RefphEntry.get() == "CB-C":
16510  CMCphase = 0.0
16511  CAVphase = PeakphaseVMC - PeakphaseVA + PhErr
16512  CMAphase = PeakphaseVMC - PeakphaseVMA + PhErrMC
16513  CMBphase = PeakphaseVMC - PeakphaseVMB - PhErrMB
16514  CMDphase = PeakphaseVMC - PeakphaseVMD - PhErrMD
16515  CAIphase = PeakphaseVMC - PeakphaseIA
16516  CBIphase = PeakphaseVMC - PeakphaseIB + PhErr
16517  elif RefphEntry.get() == "CB-D":
16518  CMDphase = 0.0
16519  CAVphase = PeakphaseVMD - PeakphaseVA + PhErr
16520  CMAphase = PeakphaseVMD - PeakphaseVMA + PhErrMD
16521  CMBphase = PeakphaseVMD - PeakphaseVMB + PhErrMC
16522  CMCphase = PeakphaseVMD - PeakphaseVMC + PhErrMD
16523  CAIphase = PeakphaseVMD - PeakphaseIA
16524  CBIphase = PeakphaseVMD - PeakphaseIB + PhErr
16525 
16526  if CAVphase > 180:
16527  CAVphase = CAVphase - 360
16528  elif CAVphase < -180:
16529  CAVphase = CAVphase + 360
16530  if CBVphase > 180:
16531  CBVphase = CBVphase - 360
16532  elif CBVphase < -180:
16533  CBVphase = CBVphase + 360
16534  if CAIphase > 180:
16535  CAIphase = CAIphase - 360
16536  elif CAIphase < -180:
16537  CAIphase = CAIphase + 360
16538  if CBIphase > 180:
16539  CBIphase = CBIphase - 360
16540  elif CBIphase < -180:
16541  CBIphase = CBIphase + 360
16542  #
16543  if vat_btn.config('text')[-1] == 'ON':
16544  MagRadius = PeakVA / VoltsperPixel
16545  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
16546  if y1 > 1500:
16547  y1 = xright
16548  elif y1 < -500:
16549  y1 = ycenter - xright
16550  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
16551  if x1 > 1500:
16552  x1 = xright
16553  elif x1 < -500:
16554  x1 = xcenter - xright
16555  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
16556  if MuxScreenStatus.get() == 0:
16557  if vbt_btn.config('text')[-1] == 'ON':
16558  MagRadius = PeakVB / VoltsperPixel
16559  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
16560  if y1 > 1500:
16561  y1 = xright
16562  elif y1 < -500:
16563  y1 = ycenter - xright
16564  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
16565  if x1 > 1500:
16566  x1 = xright
16567  elif x1 < -500:
16568  x1 = xcenter - xright
16569  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
16570  else:
16571  if ShowPB_A.get() > 0:
16572  if CMAphase > 180:
16573  CMAphase = CMAphase - 360
16574  elif CMAphase < -180:
16575  CMAphase = CMAphase + 360
16576  MagRadius = PeakVMA / VoltsperPixel
16577  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
16578  if y1 > 1500:
16579  y1 = xright
16580  elif y1 < -500:
16581  y1 = ycenter - xright
16582  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
16583  if x1 > 1500:
16584  x1 = xright
16585  elif x1 < -500:
16586  x1 = xcenter - xright
16587  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
16588  if ShowPB_B.get() > 0:
16589  if CMBphase > 180:
16590  CMBphase = CMBphase - 360
16591  elif CMBphase < -180:
16592  CMBphase = CMBphase + 360
16593  MagRadius = PeakVMB / VoltsperPixel
16594  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
16595  if y1 > 1500:
16596  y1 = xright
16597  elif y1 < -500:
16598  y1 = ycenter - xright
16599  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
16600  if x1 > 1500:
16601  x1 = xright
16602  elif x1 < -500:
16603  x1 = xcenter - xright
16604  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
16605  if ShowPB_C.get() > 0:
16606  if CMCphase > 180:
16607  CMCphase = CMCphase - 360
16608  elif CMCphase < -180:
16609  CMCphase = CMCphase + 360
16610  MagRadius = PeakVMC / VoltsperPixel
16611  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
16612  if y1 > 1500:
16613  y1 = xright
16614  elif y1 < -500:
16615  y1 = ycenter - xright
16616  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
16617  if x1 > 1500:
16618  x1 = xright
16619  elif x1 < -500:
16620  x1 = xcenter - xright
16621  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
16622  if ShowPB_D.get() > 0:
16623  if CMDphase > 180:
16624  CMDphase = CMDphase - 360
16625  elif CMDphase < -180:
16626  CMDphase = CMDphase + 360
16627  MagRadius = PeakVMD / VoltsperPixel
16628  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
16629  if y1 > 1500:
16630  y1 = xright
16631  elif y1 < -500:
16632  y1 = ycenter - xright
16633  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
16634  if x1 > 1500:
16635  x1 = xright
16636  elif x1 < -500:
16637  x1 = xcenter - xright
16638  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
16639  if iat_btn.config('text')[-1] == 'ON':
16640  MagRadius = PeakIA / mAperPixel
16641  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
16642  if y1 > 1500:
16643  y1 = xright
16644  elif y1 < -500:
16645  y1 = ycenter - xright
16646  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
16647  if x1 > 1500:
16648  x1 = xright
16649  elif x1 < -500:
16650  x1 = xcenter - xright
16651  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
16652  if ibt_btn.config('text')[-1] == 'ON':
16653  MagRadius = PeakIB / mAperPixel
16654  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
16655  if y1 > 1500:
16656  y1 = xright
16657  elif y1 < -500:
16658  y1 = ycenter - xright
16659  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
16660  if x1 > 1500:
16661  x1 = xright
16662  elif x1 < -500:
16663  x1 = xcenter - xright
16664  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
16665  if MuxScreenStatus.get() == 0:
16666  if vabt_btn.config('text')[-1] == 'ON':
16667  MagRadius = PeakVAB / VoltsperPixel
16668 
16669  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
16670  if y1 > 1500:
16671  y1 = xright
16672  elif y1 < -500:
16673  y1 = ycenter - xright
16674  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
16675  if x1 > 1500:
16676  x1 = xright
16677  elif x1 < -500:
16678  x1 = xcenter - xright
16679  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
16680 # display warning if input out of range
16681  if OverRangeFlagA == 1:
16682  x = X0LPhA+GRWPhA+10
16683  y = Y0TPhA+GRHPhA-40
16684  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16685  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16686  if OverRangeFlagB == 1:
16687  x = X0LPhA+GRWPhA+10
16688  y = Y0TPhA+GRHPhA-10
16689  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16690  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16691 # General information on top of the grid
16692  txt = " Sample rate: " + str(SAMPLErate)
16693  txt = txt + " FFT samples: " + str(SMPfft)
16694  txt = txt + " " + FFTwindowname
16695 
16696  x = X0LPhA
16697  y = 12
16698  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
16699  #
16700  x = X0LPhA + GRWPhA + 4
16701  y = 24
16702  if ChopMuxMode.get() == 0:
16703  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
16704  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16705  y = y + 24
16706  if MuxScreenStatus.get() == 0:
16707  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
16708  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16709  y = y + 24
16710  else:
16711  if ShowPB_A.get() > 0:
16712  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
16713  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16714  y = y + 24
16715  if ShowPB_B.get() > 0:
16716  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
16717  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16718  y = y + 24
16719  if ShowPB_C.get() > 0:
16720  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
16721  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16722  y = y + 24
16723  if ShowPB_D.get() > 0:
16724  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
16725  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16726  y = y + 24
16727  if iat_btn.config('text')[-1] == 'ON':
16728  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
16729  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16730  y = y + 24
16731  if ibt_btn.config('text')[-1] == 'ON':
16732  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
16733  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16734  y = y + 24
16735  if ChopMuxMode.get() == 0:
16736  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
16737  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16738  y = y + 24
16739  if MuxScreenStatus.get() == 0:
16740  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
16741  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16742  y = y + 24
16743  else:
16744  if ShowPB_A.get() > 0:
16745  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
16746  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16747  y = y + 24
16748  if ShowPB_B.get() > 0:
16749  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
16750  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16751  y = y + 24
16752  if ShowPB_C.get() > 0:
16753  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
16754  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16755  y = y + 24
16756  if ShowPB_D.get() > 0:
16757  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
16758  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16759  y = y + 24
16760  if iat_btn.config('text')[-1] == 'ON':
16761  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
16762  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16763  y = y + 24
16764  if ibt_btn.config('text')[-1] == 'ON':
16765  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
16766  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16767  y = y + 24
16768  #
16769  if ChopMuxMode.get() == 0:
16770  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
16771  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16772  y = y + 24
16773  else:
16774  txt = "Mux A Freq " + ' {0:.1f} '.format(PeakfreqVMA) + " Hertz"
16775  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16776  y = y + 24
16777 #
16778  txt = " "
16779 # print time domin measured period and frequency of displayed channels
16780  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
16781  if ETSDisp.get() > 0:
16782  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
16783  else:
16784  FindRisingEdge(VBuffA,VBuffB)
16785  if ShowC1_V.get() == 1:
16786  if MeasAHW.get() == 1:
16787  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
16788  if MeasALW.get() == 1:
16789  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
16790  if MeasADCy.get() == 1:
16791  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
16792  if MeasAPER.get() == 1:
16793  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
16794  if MeasAFREQ.get() == 1:
16795  txt = txt + " CA Freq = "
16796  ChaF = float(CHAfreq*Mulx)
16797  if ChaF < 1000:
16798  V1String = ' {0:.2f} '.format(ChaF)
16799  txt = txt + str(V1String) + " Hz "
16800  if ChaF > 1000 and ChaF < 1000000:
16801  V1String = ' {0:.2f} '.format(ChaF/1000)
16802  txt = txt + str(V1String) + " KHz "
16803  if ChaF > 1000000:
16804  V1String = ' {0:.2f} '.format(ChaF/1000000)
16805  txt = txt + str(V1String) + " MHz "
16806  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
16807  if ShowC2_V.get() == 1:
16808  if MeasBHW.get() == 1:
16809  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
16810  if MeasBLW.get() == 1:
16811  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
16812  if MeasBDCy.get() == 1:
16813  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
16814  if MeasBPER.get() == 1:
16815  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
16816  if MeasBFREQ.get() == 1:
16817  txt = txt + " CB Freq = "
16818  ChaF = float(CHBfreq*Mulx)
16819  if ChaF < 1000:
16820  V1String = ' {0:.2f} '.format(ChaF)
16821  txt = txt + str(V1String) + " Hz "
16822  if ChaF > 1000 and ChaF < 1000000:
16823  V1String = ' {0:.2f} '.format(ChaF/1000)
16824  txt = txt + str(V1String) + " KHz "
16825  if ChaF > 1000000:
16826  V1String = ' {0:.2f} '.format(ChaF/1000000)
16827  txt = txt + str(V1String) + " MHz "
16828  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
16829  if MuxScreenStatus.get() == 0:
16830  if MeasPhase.get() == 1:
16831  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16832  if MeasDelay.get() == 1:
16833  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16834 
16835  x = X0LPhA
16836  y = YBot + int(2.5 *FontSize) #
16837  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16838  txt = " "
16839  if ShowC1_V.get() == 1:
16840  # Channel A information
16841  if CHA_RC_HP.get() == 1:
16842  txt = "CHA: HP "
16843  else:
16844  txt = "CHA: "
16845  if MeasDCV1.get() == 1:
16846  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
16847  if MeasMaxV1.get() == 1:
16848  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
16849  if MeasTopV1.get() == 1:
16850  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
16851  if MeasMinV1.get() == 1:
16852  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
16853  if MeasBaseV1.get() == 1:
16854  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
16855  if MeasMidV1.get() == 1:
16856  MidV1 = (MaxV1+MinV1)/2.0
16857  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
16858  if MeasPPV1.get() == 1:
16859  PPV1 = MaxV1-MinV1
16860  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
16861  if MeasRMSV1.get() == 1:
16862  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
16863  if MeasRMSVA_B.get() == 1:
16864  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
16865  if MeasDiffAB.get() == 1:
16866  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
16867  if MeasUserA.get() == 1:
16868  try:
16869  TempValue = eval(UserAString)
16870  V1String = ' {0:.4f} '.format(TempValue)
16871  except:
16872  V1String = "####"
16873  txt = txt + UserALabel + " = " + V1String
16874  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
16875  txt = "CHA: "
16876  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
16877  txt = txt + "CHA: "
16878 
16879  if ShowC1_I.get() == 1:
16880  if MeasDCI1.get() == 1:
16881  V1String = ' {0:.2f} '.format(DCI1)
16882  txt = txt + " AvgI = " + V1String
16883  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
16884  try:
16885  Resvalue = (DCV1/DCI1)*1000
16886  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
16887  except:
16888  txt = txt + " Res = OverRange"
16889  if MeasMaxI1.get() == 1:
16890  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
16891  if MeasMinI1.get() == 1:
16892  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
16893  if MeasMidI1.get() == 1:
16894  MidI1 = (MaxI1+MinI1)/2.0
16895  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
16896  if MeasPPI1.get() == 1:
16897  PPI1 = MaxI1-MinI1
16898  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
16899  if MeasRMSI1.get() == 1:
16900  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
16901 
16902  x = X0LPhA
16903  y = YBot + int(4*FontSize) #
16904  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16905  txt= " "
16906  # Channel B information
16907  if MuxScreenStatus.get() == 1:
16908  txt = "CHB-Mux: "
16909  if Show_CBA.get() > 0:
16910  FindRisingEdge(VBuffA,VBuffMA)
16911  elif Show_CBB.get() > 0:
16912  FindRisingEdge(VBuffA,VBuffMB)
16913  elif Show_CBC.get() > 0:
16914  FindRisingEdge(VBuffA,VBuffMC)
16915  elif Show_CBD.get() > 0:
16916  FindRisingEdge(VBuffA,VBuffMD)
16917  if MeasPhase.get() == 1:
16918  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16919  if MeasDelay.get() == 1:
16920  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16921  if MeasUserB.get() == 1:
16922  try:
16923  TempValue = eval(UserBString)
16924  V1String = ' {0:.4f} '.format(TempValue)
16925  except:
16926  V1String = "####"
16927  txt = txt + UserBLabel + " = " + V1String
16928  if ShowC2_V.get() == 1:
16929  if CHB_RC_HP.get() == 1:
16930  txt = "CHB: HP "
16931  else:
16932  txt = "CHB: "
16933  if MeasDCV2.get() == 1:
16934  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
16935  if MeasMaxV2.get() == 1:
16936  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
16937  if MeasTopV2.get() == 1:
16938  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
16939  if MeasMinV2.get() == 1:
16940  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
16941  if MeasBaseV2.get() == 1:
16942  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
16943  if MeasMidV2.get() == 1:
16944  MidV2 = (MaxV2+MinV2)/2.0
16945  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
16946  if MeasPPV2.get() == 1:
16947  PPV2 = MaxV2-MinV2
16948  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
16949  if MeasRMSV2.get() == 1:
16950  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
16951  if MeasDiffBA.get() == 1:
16952  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
16953  if MeasUserB.get() == 1:
16954  try:
16955  TempValue = eval(UserBString)
16956  V1String = ' {0:.4f} '.format(TempValue)
16957  except:
16958  V1String = "####"
16959  txt = txt + UserBLabel + " = " + V1String
16960  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
16961  txt = "CHB: "
16962  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
16963  txt = txt + "CHB: "
16964  if ShowC2_I.get() == 1:
16965  if MeasDCI2.get() == 1:
16966  V1String = ' {0:.2f} '.format(DCI2)
16967  txt = txt + " AvgI = " + V1String
16968  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
16969  try:
16970  Resvalue = (DCV2/DCI2)*1000
16971  R1String = ' {0:.1f} '.format(Resvalue)
16972  txt = txt + " Res = " + R1String
16973  except:
16974  txt = txt + " Res = OverRange"
16975  if MeasMaxI2.get() == 1:
16976  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
16977  if MeasMinI2.get() == 1:
16978  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
16979  if MeasMidI2.get() == 1:
16980  MidI2 = (MaxI2+MinI2)/2.0
16981  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
16982  if MeasPPI2.get() == 1:
16983  PPI2 = MaxI2-MinI2
16984  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
16985  if MeasRMSI2.get() == 1:
16986  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
16987 
16988  x = X0LPhA
16989  y = YBot + int(5.5 *FontSize) #
16990  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16991 #
16993  global PeakVA, PeakVB, PeakIA, PeakIB
16994  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16995  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16996  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16997  global CMAphase, CMBphase, CMCphase, CMDphase
16998  global MuxScreenStatus, AppendPhAData, PhADatafilename
16999  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
17000  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
17001 
17002  # open file to save data
17003  if AppendPhAData.get() == 0:
17004  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17005  DataFile = open(PhADatafilename, 'a')
17006  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
17007 
17008  if vat_btn.config('text')[-1] == 'ON':
17009  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
17010  if MuxScreenStatus.get() == 0:
17011  if vbt_btn.config('text')[-1] == 'ON':
17012  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
17013  else:
17014  if ShowPB_A.get() > 0:
17015  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
17016  if ShowPB_B.get() > 0:
17017  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
17018  if ShowPB_C.get() > 0:
17019  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
17020  if ShowPB_D.get() > 0:
17021  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
17022  if iat_btn.config('text')[-1] == 'ON':
17023  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
17024  if ibt_btn.config('text')[-1] == 'ON':
17025  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
17026  DataFile.close()
17027 #
17029  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
17030  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
17031  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
17032  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
17033 # open file to read data from
17034  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
17035  i = 1
17036  xcenter = GRWPhA/2
17037  ycenter = (GRHPhA/2) + 14
17038  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
17039  VoltsperPixel = float(VScale.get())/Radius
17040  mAperPixel = float(IScale.get())/Radius
17041  TRadius = Radius * Vdiv.get() # 5
17042  x1 = X0LPhA
17043  x2 = X0LPhA + GRWPhA
17044  PhATrace = []
17045 # Read values from CVS file
17046  try:
17047  CSVFile = open(filename)
17048  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
17049  CSVFile.seek(0)
17050  csv_f = csv.reader(CSVFile, dialect)
17051  for row in csv_f:
17052  try:
17053  PeakMag = float(row[0])
17054  PeakPhase = float(row[1])
17055  if row[2] == "CA-I" or row[2] == "CB-I":
17056  MagRadius = PeakMag / mAperPixel
17057  else:
17058  MagRadius = PeakMag / VoltsperPixel
17059 
17060  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
17061  if y1 > 1500:
17062  y1 = xright
17063  elif y1 < -500:
17064  y1 = ycenter - xright
17065  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
17066  if x1 > 1500:
17067  x1 = xright
17068  elif x1 < -500:
17069  x1 = xcenter - xright
17070  if PhAPlotMode.get() == 0:
17071  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
17072  else:
17073  PhATrace.append(x1)
17074  PhATrace.append(y1)
17075  except:
17076  print( 'skipping non-numeric row')
17077  if PhAPlotMode.get() == 1:
17078  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
17079  CSVFile.close()
17080  except:
17081  showwarning("WARNING","No such file found or wrong format!")
17082 #
17083 #
17084 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
17085  global FFTmemoryA, FFTresultA, SMPfft
17086  global FFTmemoryB, FFTresultB
17087  global PhaseA, PhaseB, freqwindow
17088  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
17089 
17090  # Set the TRACEsize variable
17091  if ShowC1_VdB.get() == 1:
17092  TRACEsize = len(FFTresultA) # Set the trace length
17093  elif ShowC2_VdB.get() == 1:
17094  TRACEsize = len(FFTresultB)
17095  if TRACEsize == 0: # If no trace, skip rest of this routine
17096  return()
17097 # ask if save as magnitude or dB
17098  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
17099  # Make the file name and open it
17100  if dB == 0:
17101  PSD = askyesno("Mag/Root Hz? ","Save Mag in V/sqrt Hz? (yes) or (No):\n", parent=freqwindow)
17102  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
17103  filename = "Spectrum-" + tme
17104  filename = filename + ".csv"
17105  # open file to save data
17106  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
17107  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
17108  DataFile = open(filename,'a') # Open output file
17109  HeaderString = 'Frequency-#, '
17110  if ShowC1_VdB.get() == 1:
17111  if dB == 1:
17112  HeaderString = HeaderString + 'CA-dB, '
17113  if dB == 0:
17114  HeaderString = HeaderString + 'CA-Mag, '
17115  if ShowC2_VdB.get() == 1:
17116  if dB == 1:
17117  HeaderString = HeaderString + 'CB-dB, '
17118  if dB == 0:
17119  HeaderString = HeaderString + 'CB-Mag, '
17120  if ShowC1_P.get() == 1:
17121  HeaderString = HeaderString + 'Phase A-B, '
17122  if ShowC2_P.get() == 1:
17123  HeaderString = HeaderString + 'Phase B-A, '
17124  HeaderString = HeaderString + '\n'
17125  DataFile.write( HeaderString )
17126 
17127  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
17128  n = 0
17129 
17130  while n < TRACEsize:
17131  F = n * FBinWidth
17132  txt = str(F)
17133  if ShowC1_VdB.get() == 1:
17134  V = 10 * math.log10(float(FFTresultA[n])) #
17135  if dB == 0:
17136  V = 10.0**(V/20.0) # RMS Volts
17137  if PSD == 1:
17138  V = V/math.sqrt(FBinWidth) # per root Hz
17139  txt = txt + "," + str(V)
17140  if ShowC2_VdB.get() == 1:
17141  V = 10 * math.log10(float(FFTresultB[n])) #
17142  if dB == 0:
17143  V = 10.0**(V/20.0)# RMS Volts
17144  if PSD == 1:
17145  V = V/math.sqrt(FBinWidth) # per root Hz
17146  txt = txt + "," + str(V)
17147  if ShowC1_P.get() == 1:
17148  RelPhase = PhaseA[n]-PhaseB[n]
17149  if RelPhase > 180:
17150  RelPhase = RelPhase - 360
17151  elif RelPhase < -180:
17152  RelPhase = RelPhase + 360
17153  txt = txt + "," + str(RelPhase)
17154  if ShowC2_P.get() == 1:
17155  RelPhase = PhaseB[n]-PhaseA[n]
17156  if RelPhase > 180:
17157  RelPhase = RelPhase - 360
17158  elif RelPhase < -180:
17159  RelPhase = RelPhase + 360
17160  txt = txt + "," + str(RelPhase)
17161  txt = txt + "\n"
17162  DataFile.write(txt)
17163  n = n + 1
17164 
17165  DataFile.close() # Close the file
17166 
17168 def MakeFreqScreen(): # Update the screen with traces and text
17169  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
17170  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
17171  global PeakxM, PeakyM, PeakMdb, PeakfreqM
17172  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
17173  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
17174  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
17175  global COLORgrid # The colors
17176  global COLORsignalband, COLORtext
17177  global COLORtrace1, COLORtrace2
17178  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
17179  global DBdivindex # Index value
17180  global DBdivlist # dB per division list
17181  global DBlevel # Reference level
17182  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17183  global X0LF # Left top X value
17184  global Y0TF # Left top Y value
17185  global GRWF # Screenwidth
17186  global GRHF # Screenheight
17187  global FontSize
17188  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17189  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
17190  global SMPfft # number of FFT samples
17191  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17192  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
17193  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
17194  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp, ShowAWGASA, ShowAWGBSA
17195  global ShowFCur, ShowdBCur, FCursor, dBCursor
17196  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
17197  global T1PRline, T2PRline, TAFline, TBFline
17198  global TRACEaverage # Number of traces for averageing
17199  global FreqTraceMode # 1 normal 2 max 3 average
17200  global Vdiv # Number of vertical divisions
17201 
17202  # Delete all items on the screen
17203  MarkerFreqNum = 0
17204  FBinWidth = float(SAMPLErate / 2.0) / (SMPfft - 1) # Frequency step per sample
17205  Freqca.delete(ALL) # remove all items
17206  try:
17207  StartFrequency = float(StartFreqEntry.get())
17208  except:
17209  StartFreqEntry.delete(0,"end")
17210  StartFreqEntry.insert(0,100)
17211  StartFrequency = 100
17212  try:
17213  StopFrequency = float(StopFreqEntry.get())
17214  except:
17215  StopFreqEntry.delete(0,"end")
17216  StopFreqEntry.insert(0,10000)
17217  StopFrequency = 10000
17218  try:
17219  Phasecenter = int(PhCenFreqEntry.get())
17220  RelPhaseCenter.set(Phasecenter)
17221  except:
17222  PhCenFreqEntry.delete(0,"end")
17223  PhCenFreqEntry.insert(0,0)
17224  RelPhaseCenter.set(0)
17225  Phasecenter = 0
17226  # Draw horizontal grid lines
17227  i = 0
17228  x1 = X0LF
17229  x2 = X0LF + GRWF
17230  if SAVScale.get() == 0: # In dB
17231  while (i <= Vdiv.get()):
17232  y = Y0TF + i * GRHF/Vdiv.get()
17233  Dline = [x1,y,x2,y]
17234  if i == 0 or i == Vdiv.get():
17235  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17236  else:
17237  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17238  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
17239  Vaxis_label = str(Vaxis_value)
17240  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17241  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
17242  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
17243  Vaxis_value = Vaxis_value + Phasecenter
17244  Vaxis_label = str(Vaxis_value)
17245  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
17246  i = i + 1
17247  else: # In rms V
17248  if SAVScale.get() == 2: # Log Scale
17249  try:
17250  LogVStop = math.log10(SAvertmax)
17251  except:
17252  LogVStop = 0.0
17253  try:
17254  LogVStart = math.log10(SAvertmin)
17255  except:
17256  LogVStart = -10
17257  LogVpixel = (LogVStart - LogVStop) / GRHF
17258  NumDec = LogVStart - LogVStop # number of major grids
17259  Gridpixel = GRHF/NumDec # number of pixels per major grid
17260  V = NumDec
17261  while V <= 0: # Major Grid lines
17262  try:
17263  LogV = math.log10(10**V) # convet to log Volts
17264  y = Y0TF + (LogV/LogVpixel)
17265  except:
17266  y = Y0TF
17267  Dline = [x1,y,x2,y]
17268  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17269  LNum = LogVStop + V
17270  if LNum == 1.0:
17271  axis_label = "10.0"
17272  elif LNum == 0:
17273  axis_label = "1.0"
17274  elif LNum == -1:
17275  axis_label = "100mV"
17276  elif LNum == -2:
17277  axis_label = "10mV"
17278  elif LNum == -3:
17279  axis_label = "1mV"
17280  elif LNum == -4:
17281  axis_label = "100uV"
17282  elif LNum == -5:
17283  axis_label = "10uV"
17284  elif LNum == -6:
17285  axis_label = "1uV"
17286  elif LNum == -7:
17287  axis_label = "100nV"
17288  elif LNum == -8:
17289  axis_label = "10nV"
17290  else:
17291  axis_label = str(LogVStart+V)
17292  print(LNum)
17293  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17294  J = 2
17295  while J < 10: # Minor Grid lines
17296  ym = y + (Gridpixel*math.log10(J))
17297  Dline = [x1,ym,x2,ym]
17298  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17299  J = J + 1
17300  V = V + 1
17301  else: # Linear Scale
17302  i = 0
17303  Vper = (SAvertmax - SAvertmin) / Vdiv.get()
17304  while (i < Vdiv.get()+1):
17305  y = Y0TF + i * GRHF/Vdiv.get()
17306  Dline = [x1,y,x2,y]
17307  if i == 0 or i == Vdiv.get():
17308  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17309  else:
17310  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17311  axis_value = (SAvertmax - (i * Vper))
17312  axis_label = ' {0:.3f} '.format(axis_value) # str(axis_value)
17313  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17314  i = i + 1
17315  # Draw vertical grid lines
17316  i = 0
17317  y1 = Y0TF
17318  y2 = Y0TF + GRHF
17319  if HScale.get() == 1:
17320  F = 1.0
17321  LogFStop = math.log10(StopFrequency)
17322  try:
17323  LogFStart = math.log10(StartFrequency)
17324  except:
17325  LogFStart = 0.0
17326  LogFpixel = (LogFStop - LogFStart) / GRWF
17327  # draw left and right edges
17328  while F <= StopFrequency:
17329  if F >= StartFrequency:
17330  try:
17331  LogF = math.log10(F) # convet to log Freq
17332  x = X0LF + (LogF - LogFStart)/LogFpixel
17333  except:
17334  x = X0LF
17335  Dline = [x,y1,x,y2]
17336  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
17337  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17338  axis_label = str(F)
17339  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17340  else:
17341  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17342 
17343  if F < 10:
17344  F = F + 1
17345  elif F < 100:
17346  F = F + 10
17347  elif F < 1000:
17348  F = F + 100
17349  elif F < 1000:
17350  F = F + 100
17351  elif F < 10000:
17352  F = F + 1000
17353  elif F < 100000:
17354  F = F + 10000
17355  elif F < 200000:
17356  F = F + 10000
17357  else:
17358  Freqdiv = (StopFrequency - StartFrequency) / 10
17359  while (i < 11):
17360  x = X0LF + i * GRWF/10.0
17361  Dline = [x,y1,x,y2]
17362  if i == 0 or i == 10:
17363  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17364  else:
17365  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17366  axis_value = (StartFrequency + (i * Freqdiv))
17367  axis_label = str(axis_value)
17368  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17369  i = i + 1
17370  # Draw X - Y cursors if needed
17371  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17372  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17373  # Vertical conversion factors (level dBs) and border limits
17374  YVconv = float(GRHF) / (SAvertmax - SAvertmin) #
17375  YVc = float(Y0TF) + YVconv * SAvertmax
17376  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17377  if ShowFCur.get() > 0:
17378  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
17379  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17380  # Horizontal conversion factors (frequency Hz) and border limits
17381  if HScale.get() == 1:
17382  LogFStop = math.log10(StopFrequency)
17383  try:
17384  LogFStart = math.log10(StartFrequency)
17385  except:
17386  LogFStart = 0.0
17387  LogFpixel = (LogFStop - LogFStart) / GRWF
17388  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
17389  else:
17390  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17391  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
17392  XFString = ' {0:.2f} '.format(xfreq)
17393  V_label = XFString + " Hz"
17394  Freqca.create_text(FCursor+1, Y0TF+GRHF+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
17395  #Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17396 #
17397  if ShowdBCur.get() > 0:
17398  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
17399  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17400  if SAVScale.get() == 0: # In dB
17401  yvdB = ((Yc-dBCursor)/Yconv)
17402  VdBString = ' {0:.1f} '.format(yvdB)
17403  V_label = VdBString + " dBV"
17404  elif SAVScale.get() == 1: # Lin Scale
17405  yvdB = ((YVc-dBCursor)/YVconv)
17406  VdBString = ' {0:.3f} '.format(yvdB)
17407  V_label = VdBString + " Vrms"
17408  else: # Log Scale
17409  LogVpixel = (LogVStop - LogVStart) / GRHF
17410  Vlog = ((YVc - dBCursor) * LogVpixel) + LogVStart
17411  yvdB = 10**Vlog
17412  VdBString = ' {:.2e} '.format(yvdB)
17413  V_label = VdBString + " Vrms"
17414 
17415  Freqca.create_text(X0LF+GRWF-5, dBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17416  #
17417  SmoothBool = SmoothCurvesSA.get()
17418  # Draw traces
17419  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
17420  # Write the trace CHA
17421  if OverRangeFlagA == 1:
17422  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17423  else:
17424  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17425  if ShowMarker.get() > 0:
17426  k = 1
17427  while k <= HarmonicMarkers.get():
17428  FreqA = k*PeakIndexA*Fsample
17429  #
17430  if SAVScale.get() == 0: # In dB
17431  if SAVPSD.get() == 1:
17432  try:
17433  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])/math.sqrt(FBinWidth))
17434  except:
17435  dbA = -100
17436  else:
17437  try:
17438  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k]))
17439  except:
17440  dbA = -100
17441  if ShowMarker.get() == 2 and k > 1:
17442  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17443  else:
17444  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
17445  yA = Yc - Yconv * dbA
17446  else: # Volts Scale
17447  try:
17448  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])) # Convert power to DBs
17449  except:
17450  dbA = -100
17451  V = 10.0**(dbA/20.0)# convert back to RMS Volts
17452  PeakV = 10.0**(PeakdbA/20.0)# convert back to RMS Volts
17453  if SAVPSD.get() == 1: # per root Hz
17454  V = V/math.sqrt(FBinWidth)
17455  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17456  if SAVScale.get() == 2: # Log Scale
17457  LogVpixel = (LogVStop - LogVStart) / GRHF
17458  try:
17459  LogV = math.log10(V) # convet to log Volts
17460  yA = YVc - (LogV - LogVStart)/LogVpixel
17461  except:
17462  yA = YVc - YVconv * V
17463  if ShowMarker.get() == 2 and k > 1:
17464  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17465  else:
17466  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17467  else: # Lin Scale
17468  if ShowMarker.get() == 2 and k > 1:
17469  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17470  else:
17471  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17472  yA = YVc - YVconv * V
17473  #
17474  if HScale.get() == 1:
17475  try:
17476  LogF = math.log10(FreqA) # convet to log Freq
17477  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
17478  except:
17479  xA = X0LF
17480  else:
17481  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
17482 
17483  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
17484  k = k + 1
17485 
17486  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
17487  # Write the trace CHB
17488  if OverRangeFlagB == 1:
17489  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17490  else:
17491  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17492  if ShowMarker.get() > 0:
17493  k = 1
17494  while k <= HarmonicMarkers.get():
17495  FreqB = k*PeakIndexB*Fsample
17496  #
17497  if SAVScale.get() == 0: # In dB
17498  if SAVPSD.get() == 1:
17499  try:
17500  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])/math.sqrt(FBinWidth))
17501  except:
17502  dbB = -100
17503  else:
17504  try:
17505  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k]))
17506  except:
17507  dbb = -100
17508  if ShowMarker.get() == 2 and k > 1:
17509  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17510  else:
17511  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
17512  yB = Yc - Yconv * dbB
17513  else: # Volts Scale
17514  try:
17515  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])) # Convert power to DBs
17516  except:
17517  dbB = -100
17518  V = 10.0**(dbB/20.0)# convert back to RMS Volts
17519  PeakV = 10.0**(PeakdbB/20.0)# convert back to RMS Volts
17520  if SAVPSD.get() == 1: # per root Hz
17521  V = V/math.sqrt(FBinWidth)
17522  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17523  if SAVScale.get() == 2: # Log Scale
17524  LogVpixel = (LogVStop - LogVStart) / GRHF
17525  try:
17526  LogV = math.log10(V) # convet to log Volts
17527  yB = YVc - (LogV - LogVStart)/LogVpixel
17528  except:
17529  yB = YVc - YVconv * V
17530  if ShowMarker.get() == 2 and k > 1:
17531  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17532  else:
17533  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17534  else: # Lin Scale
17535  if ShowMarker.get() == 2 and k > 1:
17536  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17537  else:
17538  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17539  yB = YVc - YVconv * V
17540  #
17541  if HScale.get() == 1:
17542  try:
17543  LogF = math.log10(FreqB) # convet to log Freq
17544  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
17545  except:
17546  xB = X0LF
17547  else:
17548  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
17549 
17550  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
17551  k = k + 1
17552 #
17553  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
17554  # Write the phase trace A-B
17555  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17556  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
17557  # Write the phase trace A-B
17558  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17559  if ShowAWGASA.get() > 0 and len(TAFline) > 4: # Write the AWG trace A if active
17560  Freqca.create_line(TAFline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17561  if ShowAWGBSA.get() > 0 and len(TBFline) > 4: # Write the AWG trace B if active
17562  Freqca.create_line(TBFline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17563  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
17564  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17565  if ShowMarker.get() == 1:
17566  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
17567  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
17568  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
17569  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17570  if ShowMarker.get() == 1:
17571  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
17572  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
17573  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
17574  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17575  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
17576  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17577  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
17578  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17579  if ShowMarker.get() ==1:
17580  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
17581  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
17582  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
17583  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17584  if ShowMarker.get() ==1:
17585  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
17586  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
17587  # General information on top of the grid
17588 
17589  txt = " Sample rate: " + str(SAMPLErate)
17590  txt = txt + " FFT samples: " + str(SMPfft)
17591 
17592  txt = txt + " " + FFTwindowname
17593 
17594  x = X0LF
17595  y = 12
17596  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17597 
17598  # Start and stop frequency and dB/div and trace mode
17599  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
17600  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
17601  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
17602  if FFTwindow.get() < 7:
17603  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
17604  else:
17605  txt = txt + " FFT Bandwidth = ???"
17606 
17607  x = X0LF
17608  y = Y0TF+GRHF+23
17609  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17610 
17611  if FreqTraceMode.get() == 1:
17612  txt ="Normal mode "
17613 
17614  if FreqTraceMode.get() == 2:
17615  txt = "Peak hold mode "
17616 
17617  if FreqTraceMode.get() == 3:
17618  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
17619 
17620  if ZEROstuffing.get() > 0:
17621  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
17622  # Runstatus and level information
17623  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
17624  txt = txt + " Stopped "
17625  elif SingleShotSA.get() == 1:
17626  txt = txt + " Single Shot Trace "
17627  else:
17628  if FreqDisp.get() == 1:
17629  txt = txt + " Running "
17630  else:
17631  txt = txt + " Display off "
17632  x = X0LF
17633  y = Y0TF+GRHF+34
17634  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17635 
17637  global SMPfft, FFTwindow
17638  global SMPfftpwrTwo, BodeDisp
17639  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
17640 
17641  # First some subroutines to set specific variables
17642  if BodeDisp.get() == 0:
17643  if FFTwindow.get() != 8:
17644  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
17645 
17647  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
17648  TRACEresetFreq = True # Clear the memory for averaging or peak
17649  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
17650  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
17651 
17652 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
17653  global FFTbandwidth # The FFT bandwidth
17654  global FFTwindow # Which FFT window number is selected
17655  global FFTwindowname # The name of the FFT window function
17656  global FFTwindowshape # The window shape
17657  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
17658  global SMPfft # Number of FFT samples
17659  global LastWindow, LastSMPfft
17660 
17661  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
17662  # recalculate window only if something changed
17663  return
17664  # FFTname and FFTbandwidth in milliHz
17665  FFTwindowname = "No such window"
17666  FFTbw = 0
17667 
17668  if FFTwindow.get() == 0:
17669  FFTwindowname = " Rectangular (no) window (B=1) "
17670  FFTbw = 1.0
17671 
17672  if FFTwindow.get() == 1:
17673  FFTwindowname = " Cosine window (B=1.24) "
17674  FFTbw = 1.24
17675 
17676  if FFTwindow.get() == 2:
17677  FFTwindowname = " Triangular window (B=1.33) "
17678  FFTbw = 1.33
17679 
17680  if FFTwindow.get() == 3:
17681  FFTwindowname = " Hann window (B=1.5) "
17682  FFTbw = 1.5
17683 
17684  if FFTwindow.get() == 4:
17685  FFTwindowname = " Blackman window (B=1.73) "
17686  FFTbw = 1.73
17687 
17688  if FFTwindow.get() == 5:
17689  FFTwindowname = " Nuttall window (B=2.02) "
17690  FFTbw = 2.02
17691 
17692  if FFTwindow.get() == 6:
17693  FFTwindowname = " Flat top window (B=3.77) "
17694  FFTbw = 3.77
17695 
17696  if FFTwindow.get() == 7:
17697  FFTwindowname = FFTUserWindowString
17698  FFTbw = 0.0
17699  try:
17700  FFTwindowshape = eval(FFTUserWindowString)
17701  except:
17702  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17703  print( "Filling FFT window with Ones")
17704  elif FFTwindow.get() == 8: # window shape array read from csv file
17705  FFTwindowname = "Window Shape From file"
17706  FFTbw = 0.0
17707  else:
17708  FFTbandwidth = int(FFTbw * (SAMPLErate/2.0) / float(SMPfft))
17709  # Calculate the shape
17710  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17711  n = 0
17712  while n < SMPfft:
17713  # Cosine window function - medium-dynamic range B=1.24
17714  if FFTwindow.get() == 1:
17715  w = math.sin(math.pi * n / (SMPfft - 1))
17716  FFTwindowshape[n] = w * 1.571
17717  # Triangular non-zero endpoints - medium-dynamic range B=1.33
17718  if FFTwindow.get() == 2:
17719  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
17720  FFTwindowshape[n] = w * 2.0
17721  # Hann window function - medium-dynamic range B=1.5
17722  if FFTwindow.get() == 3:
17723  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
17724  FFTwindowshape[n] = w * 2.000
17725  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
17726  if FFTwindow.get() == 4:
17727  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
17728  FFTwindowshape[n] = w * 2.381
17729  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
17730  if FFTwindow.get() == 5:
17731  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
17732  FFTwindowshape[n] = w * 2.811
17733  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
17734  if FFTwindow.get() == 6:
17735  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
17736  FFTwindowshape[n] = w * 1.000
17737  n = n + 1
17738  LastWindow = FFTwindow.get()
17739  LastSMPfft = SMPfft
17740 
17742  global FFTUserWindowString, freqwindow
17743 
17744  TempString = FFTUserWindowString
17745  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
17746  if (FFTUserWindowString == None): # If Cancel pressed, then None
17747  FFTUserWindowString = TempString
17748 
17750  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
17751 
17752  # Read values from CVS file
17753  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
17754  try:
17755  CSVFile = open(filename)
17756  csv_f = csv.reader(CSVFile)
17757  FFTwindowshape = []
17758  for row in csv_f:
17759  try:
17760  FFTwindowshape.append(float(row[0]))
17761  except:
17762  print( 'skipping non-numeric row')
17763  FFTwindowshape = numpy.array(FFTwindowshape)
17764  CSVFile.close()
17765  SMPfft = len(FFTwindowshape)
17766  LastSMPfft = SMPfft
17767  LastWindow = FFTwindow.get()
17768  print( SMPfft)
17769  except:
17770  showwarning("WARNING","No such file found or wrong format!")
17771 #
17773  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17774 
17775  FCursor = event.x
17776  dBCursor = event.y
17777  if RUNstatus.get() == 0:
17779  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
17780  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
17781  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
17782 #
17784  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17785 
17786  if event.widget == Freqca:
17787  ShiftKeyDwn = event.state & 1
17788  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
17789  # respond to Linux or Windows wheel event
17790  if event.num == 5 or event.delta == -120:
17791  FCursor -= 1
17792  if event.num == 4 or event.delta == 120:
17793  FCursor += 1
17794  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
17795  # respond to Linux or Windows wheel event
17796  if event.num == 5 or event.delta == -120:
17797  dBCursor += 1
17798  if event.num == 4 or event.delta == 120:
17799  dBCursor -= 1
17800  if RUNstatus.get() == 0:
17802 #
17804  global X0LF # Left top X value
17805  global Y0TF # Left top Y value
17806  global GRWF # Screenwidth
17807  global GRHF # Screenheight
17808  global FontSize
17809  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
17810  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
17811  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
17812  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
17813  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17814 
17815  if (RUNstatus.get() == 0):
17816  MarkerFreqNum = MarkerFreqNum + 1
17817  COLORmarker = COLORgrid
17818  if ShowC1_VdB.get() == 1:
17819  COLORmarker = COLORtrace1
17820  elif ShowC2_VdB.get() == 1:
17821  COLORmarker = COLORtrace2
17822  try:
17823  StartFrequency = float(StartFreqEntry.get())
17824  except:
17825  StartFreqEntry.delete(0,"end")
17826  StartFreqEntry.insert(0,100)
17827  StartFrequency = 100
17828  try:
17829  StopFrequency = float(StopFreqEntry.get())
17830  except:
17831  StopFreqEntry.delete(0,"end")
17832  StopFreqEntry.insert(0,100)
17833  StopFrequency = 100
17834  # draw X at marker point and number
17835  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
17836  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
17837  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
17838  # Vertical conversion factors (level dBs) and border limits
17839  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17840  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
17841  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17842  YVc = float(Y0TF) + YVconv * SAvertmax
17843  Yphconv = float(GRHF) / 360
17844  Yp = float(Y0TF) + Yphconv + 180
17845  # Horizontal conversion factors (frequency Hz) and border limits
17846  if HScale.get() == 1:
17847  LogFStop = math.log10(StopFrequency)
17848  try:
17849  LogFStart = math.log10(StartFrequency)
17850  except:
17851  LogFStart = 0.0
17852  LogFpixel = (LogFStop - LogFStart) / GRWF
17853  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
17854  else:
17855  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17856  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
17857  #
17858  try:
17859  LogVStop = math.log10(SAvertmax)
17860  except:
17861  LogVStop = 0.0
17862  try:
17863  LogVStart = math.log10(SAvertmin)
17864  except:
17865  LogVStart = -10
17866  LogVpixel = (LogVStop - LogVStart) / GRHF
17867  #
17868  XFString = ' {0:.2f} '.format(xfreq)
17869  if SAVScale.get() == 0:
17870  yvdB = ((Yc-event.y)/Yconv)
17871  VdBString = ' {0:.3f} '.format(yvdB)
17872  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
17873  else:
17874  if SAVScale.get() == 1:
17875  yvdB = ((YVc-event.y)/YVconv)
17876  VdBString = ' {0:.3f} '.format(yvdB)
17877  else:
17878  Vlog = ((YVc - event.y) * LogVpixel) + LogVStart
17879  yvdB = 10**Vlog
17880  VdBString = ' {:.2e} '.format(yvdB)
17881  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " Vrms"
17882 
17883  if MarkerFreqNum > 1:
17884  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17885  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
17886  if SAVScale.get() == 0:
17887  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17888  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
17889  else:
17890  if SAVScale.get() == 1:
17891  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17892  else:
17893  DeltaV = ' {0:.2e} '.format(yvdB-PrevdBV)
17894  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " Vrms"
17895  x = X0LF + 5
17896  y = Y0TF + 3 + (MarkerFreqNum*10)
17897  Justify = 'w'
17898  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
17899  x = X0LF + GRWF - 5
17900  y = Y0TF + 3 + (MarkerFreqNum*10)
17901  Justify = 'e'
17902  if MarkerLoc == 'LL' or MarkerLoc == 'll':
17903  x = X0LF + 5
17904  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17905  Justify = 'w'
17906  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
17907  x = X0LF + GRWF - 5
17908  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17909  Justify = 'e'
17910  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
17911  PrevdBV = yvdB
17912  PrevF = xfreq
17913 #
17914 def onCanvasSAOne(event):
17915  global ShowC1_VdB
17916  if ShowC1_VdB.get() == 0:
17917  ShowC1_VdB.set(1)
17918  else:
17919  ShowC1_VdB.set(0)
17920 #
17921 def onCanvasSATwo(event):
17922  global ShowC2_VdB
17923  if ShowC2_VdB.get() == 0:
17924  ShowC2_VdB.set(1)
17925  else:
17926  ShowC2_VdB.set(0)
17927 #
17928 def onCanvasSAThree(event):
17929  global ShowC1_P
17930  if ShowC1_P.get() == 0:
17931  ShowC1_P.set(1)
17932  else:
17933  ShowC1_P.set(0)
17934 #
17935 def onCanvasSAFour(event):
17936  global ShowC2_P
17937  if ShowC2_P.get() == 0:
17938  ShowC2_P.set(1)
17939  else:
17940  ShowC2_P.set(0)
17941 #
17942 def onCanvasSAFive(event):
17943  global ShowMarker
17944  if ShowMarker.get() == 0:
17945  ShowMarker.set(1)
17946  else:
17947  ShowMarker.set(0)
17948 #
17949 def onCanvasSASix(event):
17950  global ShowRA_VdB
17951  if ShowRA_VdB.get() == 0:
17952  ShowRA_VdB.set(1)
17953  else:
17954  ShowRA_VdB.set(0)
17955 #
17956 def onCanvasSASeven(event):
17957  global ShowRB_VdB
17958  if ShowRB_VdB.get() == 0:
17959  ShowRB_VdB.set(1)
17960  else:
17961  ShowRB_VdB.set(0)
17962 #
17963 def onCanvasSAEight(event):
17964  global ShowMathSA
17965  ShowMathSA.set(2)
17966 #
17967 def onCanvasSANine(event):
17968  global ShowMathSA
17969  ShowMathSA.set(1)
17970 #
17971 def onCanvasSAZero(event):
17972  global ShowMathSA
17973  ShowMathSA.set(0)
17974 #
17975 def onCanvasSASnap(event):
17976  BSTOREtraceSA()
17977 #
17978 def onCanvasSANormal(event):
17979  BNormalmode()
17980 #
17981 def onCanvasSAPeak(event):
17982  BPeakholdmode()
17983 
17984 def onCanvasSAReset(event):
17985  BResetFreqAvg()
17986 #
17988  BAveragemode()
17989 #
17990 def onCanvasShowFcur(event):
17991  global ShowFCur
17992  if ShowFCur.get() == 0:
17993  ShowFCur.set(1)
17994  else:
17995  ShowFCur.set(0)
17996 #
17998  global ShowdBCur
17999  if ShowdBCur.get() == 1:
18000  ShowdBCur.set(0)
18001  else:
18002  ShowdBCur.set(1)
18003 #
18004 def onCanvasShowPcur(event):
18005  global ShowdBCur
18006  if ShowdBCur.get() == 2:
18007  ShowdBCur.set(0)
18008  else:
18009  ShowdBCur.set(2)
18010 #
18012  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
18013 
18014  BPCursor = event.x
18015  BdBCursor = event.y
18016  if RUNstatus.get() == 0:
18018  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
18019  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
18020  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
18021  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
18022 #
18024  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
18025 
18026  # print event.state
18027  shift_key = event.state & 1
18028  if ShowBPCur.get() > 0 and shift_key == 0:
18029  # respond to Linux or Windows wheel event
18030  if event.num == 5 or event.delta == -120:
18031  BPCursor -= 1
18032  if event.num == 4 or event.delta == 120:
18033  BPCursor += 1
18034  elif ShowBdBCur.get() > 0 or shift_key == 1:
18035  # respond to Linux or Windows wheel event
18036  if event.num == 5 or event.delta == -120:
18037  BdBCursor += 1
18038  if event.num == 4 or event.delta == 120:
18039  BdBCursor -= 1
18040  if RUNstatus.get() == 0:
18042 #
18044  global X0LBP # Left top X value
18045  global Y0TBP # Left top Y value
18046  global GRWBP # Screenwidth
18047  global GRHBP # Screenheight
18048  global FontSize
18049  global Bodeca, MarkerLoc, SAMPLErate
18050  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
18051  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
18052  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
18053 
18054  if (RUNstatus.get() == 0):
18055  MarkerFreqNum = MarkerFreqNum + 1
18056  COLORmarker = COLORtrace6 # COLORgrid
18057  if ShowCA_VdB.get() == 1:
18058  COLORmarker = COLORtrace1
18059  elif ShowCB_VdB.get() == 1:
18060  COLORmarker = COLORtrace2
18061  try:
18062  EndFreq = float(StopBodeEntry.get())
18063  except:
18064  StopBodeEntry.delete(0,"end")
18065  StopBodeEntry.insert(0,10000)
18066  EndFreq = 10000
18067  try:
18068  BeginFreq = float(StartBodeEntry.get())
18069  except:
18070  StartBodeEntry.delete(0,"end")
18071  StartBodeEntry.insert(0,100)
18072  BeginFreq = 100
18073  # draw X at marker point and number
18074  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
18075  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
18076  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
18077  # Vertical conversion factors (level dBs) and border limits
18078  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
18079  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
18080  Yphconv = float(GRHBP) / 360
18081  Yp = float(Y0TBP) + Yphconv + 180
18082  x1 = X0LBP + 14
18083  x2 = x1 + GRWBP
18084  # Horizontal conversion factors (frequency Hz) and border limits
18085  if HScaleBP.get() == 1:
18086  LogFStop = math.log10(EndFreq)
18087  try:
18088  LogFStart = math.log10(BeginFreq)
18089  except:
18090  LogFStart = 0.0
18091  LogFpixel = (LogFStop - LogFStart) / GRWBP
18092  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
18093  else:
18094  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
18095  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
18096 
18097  yvdB = ((Yc-event.y)/Yconv)
18098  VdBString = ' {0:.1f} '.format(yvdB)
18099  XFString = ' {0:.2f} '.format(xfreq)
18100  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18101  if MarkerFreqNum > 1:
18102  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18103  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18104  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18105  x = x1 + 5
18106  y = Y0TBP + 3 + (MarkerFreqNum*10)
18107  Justify = 'w'
18108  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18109  x = x2 - 5
18110  y = Y0TBP + 3 + (MarkerFreqNum*10)
18111  Justify = 'e'
18112  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18113  x = x1 + 5
18114  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18115  Justify = 'w'
18116  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18117  x = x2 - 5
18118  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18119  Justify = 'e'
18120  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18121  PrevdBV = yvdB
18122  PrevF = xfreq
18123 #
18124 def onCanvasBdOne(event):
18125  global ShowCA_VdB
18126  if ShowCA_VdB.get() == 0:
18127  ShowCA_VdB.set(1)
18128  else:
18129  ShowCA_VdB.set(0)
18130 #
18131 def onCanvasBdTwo(event):
18132  global ShowCB_VdB
18133  if ShowCB_VdB.get() == 0:
18134  ShowCB_VdB.set(1)
18135  else:
18136  ShowCB_VdB.set(0)
18137 #
18138 def onCanvasBdThree(event):
18139  global ShowCA_P
18140  if ShowCA_P.get() == 0:
18141  ShowCA_P.set(1)
18142  else:
18143  ShowCA_P.set(0)
18144 #
18145 def onCanvasBdFour(event):
18146  global ShowCB_P
18147  if ShowCB_P.get() == 0:
18148  ShowCB_P.set(1)
18149  else:
18150  ShowCB_P.set(0)
18151 #
18152 def onCanvasBdFive(event):
18153  global ShowMarkerBP
18154  if ShowMarkerBP.get() == 0:
18155  ShowMarkerBP.set(1)
18156  else:
18157  ShowMarkerBP.set(0)
18158 #
18159 def onCanvasBdSix(event):
18160  global ShowRA_VdB
18161  if ShowRA_VdB.get() == 0:
18162  ShowRA_VdB.set(1)
18163  else:
18164  ShowRA_VdB.set(0)
18165 #
18166 def onCanvasBdSeven(event):
18167  global ShowRB_VdB
18168  if ShowRB_VdB.get() == 0:
18169  ShowRB_VdB.set(1)
18170  else:
18171  ShowRB_VdB.set(0)
18172 #
18173 def onCanvasBdEight(event):
18174  global ShowMathBP
18175  ShowMathBP.set(2)
18176 #
18177 def onCanvasBdNine(event):
18178  global ShowMathBP
18179  ShowMathBP.set(1)
18180 #
18181 def onCanvasBdZero(event):
18182  global ShowMathBP
18183  ShowMathBP.set(0)
18184 #
18185 def onCanvasBdSnap(event):
18186  BSTOREtraceBP()
18187 #
18189  global ShowBPCur
18190  if ShowBPCur.get() == 0:
18191  ShowBPCur.set(1)
18192  else:
18193  ShowBPCur.set(0)
18194 #
18196  global ShowBdBCur
18197  if ShowBdBCur.get() == 1:
18198  ShowBdBCur.set(0)
18199  else:
18200  ShowBdBCur.set(1)
18201 #
18203  global ShowBdBCur
18204  if ShowBdBCur.get() == 2:
18205  ShowBdBCur.set(0)
18206  else:
18207  ShowBdBCur.set(2)
18208 #
18209 def onAWGAscroll(event):
18210  global AWGAShape
18211 
18212  onTextScroll(event)
18213  time.sleep(0.05)
18214  ReMakeAWGwaves()
18215  time.sleep(0.05)
18216 #
18217 def onAWGBscroll(event):
18218  global AWGBShape
18219 
18220  onTextScroll(event)
18221  time.sleep(0.05)
18222  ReMakeAWGwaves()
18223  time.sleep(0.05)
18224 #
18225 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
18226  button = event.widget
18227  cursor_position = button.index(INSERT) # get current cursor position
18228  Pos = cursor_position
18229  OldVal = button.get() # get current entry string
18230  OldValfl = float(OldVal) # and its value
18231  NewVal = OldValfl
18232  Len = len(OldVal)
18233  Dot = OldVal.find (".") # find decimal point position
18234  Decimals = Len - Dot - 1
18235  if Dot == -1 : # no point
18236  Decimals = 0
18237  Step = 10**(Len - Pos)
18238  elif Pos <= Dot : # no point left of position
18239  Step = 10**(Dot - Pos)
18240  else:
18241  Step = 10**(Dot - Pos + 1)
18242  # respond to Linux or Windows wheel event
18243  if event.num == 5 or event.delta == -120:
18244  NewVal = OldValfl - Step
18245  if event.num == 4 or event.delta == 120:
18246  NewVal = OldValfl + Step
18247  FormatStr = "{0:." + str(Decimals) + "f}"
18248  NewStr = FormatStr.format(NewVal)
18249  NewDot = NewStr.find (".")
18250  NewPos = Pos + NewDot - Dot
18251  if Decimals == 0 :
18252  NewLen = len(NewStr)
18253  NewPos = Pos + NewLen - Len
18254  button.delete(0, END) # remove old entry
18255  button.insert(0, NewStr) # insert new entry
18256  button.icursor(NewPos) # resets the insertion cursor
18257 #
18258 def onAWGAkey(event):
18259  global AWGAShape
18260 
18261  onTextKey(event)
18262  ReMakeAWGwaves()
18263 #
18264 def onAWGBkey(event):
18265  global AWGBShape
18266 
18267  onTextKey(event)
18268  ReMakeAWGwaves()
18269 #
18270 def onTextKeyAWG(event):
18271  onTextKey(event)
18272  ReMakeAWGwaves()
18273 #
18274 # Use Arriw keys to inc dec entry values
18275 def onTextKey(event):
18276  button = event.widget
18277  cursor_position = button.index(INSERT) # get current cursor position
18278  Pos = cursor_position
18279  OldVal = button.get() # get current entry string
18280  OldValfl = float(OldVal) # and its value
18281  Len = len(OldVal)
18282  Dot = OldVal.find (".") # find decimal point position
18283  Decimals = Len - Dot - 1
18284  if Dot == -1 : # no point
18285  Decimals = 0
18286  Step = 10**(Len - Pos)
18287  elif Pos <= Dot : # no point left of position
18288  Step = 10**(Dot - Pos)
18289  else:
18290  Step = 10**(Dot - Pos + 1)
18291  if platform.system() == "Windows":
18292  if event.keycode == 38: # increment digit for up arrow key
18293  NewVal = OldValfl + Step
18294  elif event.keycode == 40: # decrement digit for down arrow
18295  NewVal = OldValfl - Step
18296  else:
18297  return
18298  elif platform.system() == "Linux":
18299  if event.keycode == 111: # increment digit for up arrow key
18300  NewVal = OldValfl + Step
18301  elif event.keycode == 116: # decrement digit for down arrow
18302  NewVal = OldValfl - Step
18303  else:
18304  return
18305  elif platform.system() == "Darwin":
18306  if event.keycode == 0x7D: # increment digit for up arrow key
18307  NewVal = OldValfl + Step
18308  elif event.keycode == 0x7E: # decrement digit for down arrow
18309  NewVal = OldValfl - Step
18310  else:
18311  return
18312  else:
18313  return
18314 #
18315  FormatStr = "{0:." + str(Decimals) + "f}"
18316  NewStr = FormatStr.format(NewVal)
18317  NewDot = NewStr.find (".")
18318  NewPos = Pos + NewDot - Dot
18319  if Decimals == 0 :
18320  NewLen = len(NewStr)
18321  NewPos = Pos + NewLen - Len
18322  button.delete(0, END) # remove old entry
18323  button.insert(0, NewStr) # insert new entry
18324  button.icursor(NewPos) # resets the insertion cursor
18325 #
18326 #
18327 def onSpinBoxScroll(event):
18328  spbox = event.widget
18329  if sys.version_info[0] == 3 and sys.version_info[1] > 6: # Spin Boxes do this automatically in Python > 3.6 apparently
18330  return
18331  if event.num == 4 or event.delta > 0: # if event.delta > 0: # increment digit
18332  spbox.invoke('buttonup')
18333  if event.num == 5 or event.delta < 0:
18334  spbox.invoke('buttondown')
18335 #
18336 # ================ Make awg sub window ==========================
18338  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
18339  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
18340  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
18341  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
18342  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
18343  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
18344  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
18345  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
18346  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
18347  global ModeAMenu, ShapeAMenu, amp1lab, off1lab, freq1lab, awgaph, awgadel, ModeBMenu, ShapeBMenu
18348  global amp2lab, off2lab, freq2lab, awgbph, awgbdel, bcompa, awgsync
18349  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise, NoiseList
18350 
18351  if AWGScreenStatus.get() == 0:
18352  AWGScreenStatus.set(1)
18353 
18354  awgwindow = Toplevel()
18355  awgwindow.title("AWG Controls " + SWRev + RevDate)
18356  awgwindow.resizable(FALSE,FALSE)
18357  awgwindow.geometry('+0+100')
18358  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
18359  #
18360  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
18361  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
18362  #
18363  if AwgLayout == "Horz":
18364  frame2.pack(side=LEFT, expand=1, fill=X)
18365  frame3.pack(side=LEFT, expand=1, fill=X)
18366  else:
18367  frame2.pack(side=TOP, expand=1, fill=Y)
18368  frame3.pack(side=TOP, expand=1, fill=Y)
18369  # now AWG A
18370  # AWG enable sub frame
18371  awg1eb = Frame( frame2 )
18372  awg1eb.pack(side=TOP)
18373  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
18374  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
18375  ModeAMenu["menu"] = ModeAMenu.menu
18376  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18377  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
18378  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
18379  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
18380  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
18381  ModeAMenu.menu.add_separator()
18382  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18383  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
18384  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
18385  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
18386  ModeAMenu.pack(side=LEFT, anchor=W)
18387  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
18388  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
18389  ShapeAMenu["menu"] = ShapeAMenu.menu
18390  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18391  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
18392  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
18393  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
18394  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
18395  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
18396  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
18397  if AWGShowAdvanced.get() > 0:
18398  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18399  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
18400  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
18401  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
18402  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
18403  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
18404  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
18405  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
18406  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
18407  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
18408  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
18409  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
18410  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
18411  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
18412  else:
18413  ShapeAMenu.menu.add_separator()
18414  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
18415  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
18416  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
18417  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
18418  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
18419  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
18420  ShapeAMenu.pack(side=LEFT, anchor=W)
18421  #
18422  AWGAModeLabel = Label(frame2, text="AWG A Mode")
18423  AWGAModeLabel.pack(side=TOP)
18424  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
18425  AWGAShapeLabel.pack(side=TOP)
18426  #
18427  awg1ampl = Frame( frame2 )
18428  awg1ampl.pack(side=TOP)
18429  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
18430  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
18431  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
18432  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18433  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
18434  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
18435  AWGAAmplEntry.pack(side=LEFT, anchor=W)
18436  AWGAAmplEntry.delete(0,"end")
18437  AWGAAmplEntry.insert(0,0.0)
18438  amp1lab = Label(awg1ampl) #, text="Min Ch A")
18439  amp1lab.pack(side=LEFT, anchor=W)
18440  #
18441  awg1off = Frame( frame2 )
18442  awg1off.pack(side=TOP)
18443  AWGAOffsetEntry = Entry(awg1off, width=5, cursor='double_arrow')
18444  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
18445  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
18446  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18447  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
18448  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
18449  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
18450  AWGAOffsetEntry.delete(0,"end")
18451  AWGAOffsetEntry.insert(0,0.0)
18452  off1lab = Label(awg1off) #, text="Max Ch A")
18453  off1lab.pack(side=LEFT, anchor=W)
18454  if AWG_Amp_Mode.get() == 0:
18455  amp1lab.config(text = "Min Ch A" ) # change displayed value
18456  off1lab.config(text = "Max Ch A" ) # change displayed value
18457  else:
18458  amp1lab.config(text = "Amp Ch A" )
18459  off1lab.config(text = "Off Ch A" )
18460  # AWG Frequency sub frame
18461  awg1freq = Frame( frame2 )
18462  awg1freq.pack(side=TOP)
18463  AWGAFreqEntry = Entry(awg1freq, width=7, cursor='double_arrow')
18464  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
18465  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
18466  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18467  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
18468  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
18469  AWGAFreqEntry.pack(side=LEFT, anchor=W)
18470  AWGAFreqEntry.delete(0,"end")
18471  AWGAFreqEntry.insert(0,100.0)
18472  freq1lab = Label(awg1freq, text="Freq Ch A")
18473  freq1lab.pack(side=LEFT, anchor=W)
18474  # AWG Phase or delay select sub frame
18475  # AWG Phase entry sub frame
18476  awg1phase = Frame( frame2 )
18477  awg1phase.pack(side=TOP)
18478  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
18479  awgaph.pack(side=LEFT, anchor=W)
18480  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
18481  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
18482  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
18483  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18484  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
18485  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
18486  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
18487  AWGAPhaseEntry.delete(0,"end")
18488  AWGAPhaseEntry.insert(0,0)
18489  phasealab = Label(awg1phase, text="Deg")
18490  phasealab.pack(side=LEFT, anchor=W)
18491  # AWG duty cycle frame
18492  awg1dc = Frame( frame2 )
18493  awg1dc.pack(side=TOP)
18494  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
18495  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18496  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
18497  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18498  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
18499  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
18500  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
18501  AWGADutyCycleEntry.delete(0,"end")
18502  AWGADutyCycleEntry.insert(0,50)
18503  duty1lab = Label(awg1dc, text="%")
18504  duty1lab.pack(side=LEFT, anchor=W)
18505  #
18506  AWGALength = Label(frame2, text="Length")
18507  AWGALength.pack(side=TOP)
18508  # Noise Controls
18509  anoise = Frame( frame2 )
18510  anoise.pack(side=TOP)
18511  AWGANoise = Label(anoise, text="Noise")
18512  AWGANoise.pack(side=LEFT, anchor=W)
18513  AWGAsbnoise = Spinbox(anoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18514  AWGAsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18515  AWGAsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18516  AWGAsbnoise.bind("<Button-5>", onSpinBoxScroll)
18517  AWGAsbnoise.pack(side=LEFT, anchor=W)
18518  AWGANoiseEntry = Entry(anoise, width=5, cursor='double_arrow')
18519  AWGANoiseEntry.bind("<Return>", UpdateAwgContRet)
18520  AWGANoiseEntry.bind('<MouseWheel>', onAWGAscroll)
18521  AWGANoiseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18522  AWGANoiseEntry.bind("<Button-5>", onAWGAscroll)
18523  AWGANoiseEntry.bind('<Key>', onTextKeyAWG)
18524  AWGANoiseEntry.pack(side=LEFT, anchor=W)
18525  AWGANoiseEntry.delete(0,"end")
18526  AWGANoiseEntry.insert(0,0.0)
18527  #
18528  if FWRevOne > 2.16:
18529  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
18530  awg2x1.pack(side=TOP)
18531  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
18532  awg2x2.pack(side=TOP)
18533  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
18534  awg2x3.pack(side=TOP)
18535  else:
18536  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18537  awgsync.pack(side=TOP)
18538  # now AWG B
18539  # AWG enable sub frame
18540  awg2eb = Frame( frame3 )
18541  awg2eb.pack(side=TOP)
18542  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
18543  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
18544  ModeBMenu["menu"] = ModeBMenu.menu
18545  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18546  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
18547  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
18548  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
18549  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
18550  ModeBMenu.menu.add_separator()
18551  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18552  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
18553  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
18554  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
18555  ModeBMenu.pack(side=LEFT, anchor=W)
18556  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
18557  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
18558  ShapeBMenu["menu"] = ShapeBMenu.menu
18559  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18560  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
18561  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
18562  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
18563  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
18564  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
18565  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
18566  if AWGShowAdvanced.get() > 0:
18567  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18568  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
18569  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
18570  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
18571  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
18572  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
18573  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
18574  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
18575  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
18576  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
18577  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
18578  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
18579  else:
18580  ShapeBMenu.menu.add_separator()
18581  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
18582  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
18583  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
18584  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
18585  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
18586  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
18587  ShapeBMenu.pack(side=LEFT, anchor=W)
18588  #
18589  AWGBModeLabel = Label(frame3, text="AWG B Mode")
18590  AWGBModeLabel.pack(side=TOP)
18591  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
18592  AWGBShapeLabel.pack(side=TOP)
18593  #
18594  awg2ampl = Frame( frame3 )
18595  awg2ampl.pack(side=TOP)
18596  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
18597  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
18598  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
18599  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18600  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
18601  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
18602  AWGBAmplEntry.pack(side=LEFT, anchor=W)
18603  AWGBAmplEntry.delete(0,"end")
18604  AWGBAmplEntry.insert(0,0.0)
18605  amp2lab = Label(awg2ampl) #, text="Min Ch B")
18606  amp2lab.pack(side=LEFT, anchor=W)
18607  #
18608  awg2off = Frame( frame3 )
18609  awg2off.pack(side=TOP)
18610  AWGBOffsetEntry = Entry(awg2off, width=5, cursor='double_arrow')
18611  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
18612  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
18613  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18614  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
18615  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
18616  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
18617  AWGBOffsetEntry.delete(0,"end")
18618  AWGBOffsetEntry.insert(0,0.0)
18619  off2lab = Label(awg2off) #, text="Max Ch B")
18620  off2lab.pack(side=LEFT, anchor=W)
18621  if AWG_Amp_Mode.get() == 0:
18622  amp2lab.config(text = "Min Ch B" ) # change displayed value
18623  off2lab.config(text = "Max Ch B" ) # change displayed value
18624  else:
18625  amp2lab.config(text = "Amp Ch B" )
18626  off2lab.config(text = "Off Ch B" )
18627  # AWG Frequency sub frame
18628  awg2freq = Frame( frame3 )
18629  awg2freq.pack(side=TOP)
18630  AWGBFreqEntry = Entry(awg2freq, width=7, cursor='double_arrow')
18631  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
18632  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
18633  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18634  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
18635  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
18636  AWGBFreqEntry.pack(side=LEFT, anchor=W)
18637  AWGBFreqEntry.delete(0,"end")
18638  AWGBFreqEntry.insert(0,100.0)
18639  freq2lab = Label(awg2freq, text="Freq Ch B")
18640  freq2lab.pack(side=LEFT, anchor=W)
18641  # AWG Phase or delay select sub frame
18642  # AWG Phase sub frame
18643  awg2phase = Frame( frame3 )
18644  awg2phase.pack(side=TOP)
18645  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
18646  awgbph.pack(side=LEFT, anchor=W)
18647  AWGBPhaseEntry = Entry(awg2phase, width=4, cursor='double_arrow')
18648  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
18649  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
18650  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18651  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
18652  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
18653  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
18654  AWGBPhaseEntry.delete(0,"end")
18655  AWGBPhaseEntry.insert(0,0)
18656  phaseblab = Label(awg2phase, text="Deg")
18657  phaseblab.pack(side=LEFT, anchor=W)
18658  # AWG duty cycle frame
18659  awg2dc = Frame( frame3 )
18660  awg2dc.pack(side=TOP)
18661  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
18662  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18663  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
18664  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18665  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
18666  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
18667  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
18668  AWGBDutyCycleEntry.delete(0,"end")
18669  AWGBDutyCycleEntry.insert(0,50)
18670  duty2lab = Label(awg2dc, text="%")
18671  duty2lab.pack(side=LEFT, anchor=W)
18672  #
18673  AWGBLength = Label(frame3, text="Length")
18674  AWGBLength.pack(side=TOP)
18675  # Noise Controls
18676  bnoise = Frame( frame3 )
18677  bnoise.pack(side=TOP)
18678  AWGBNoise = Label(bnoise, text="Noise")
18679  AWGBNoise.pack(side=LEFT, anchor=W)
18680  AWGBsbnoise = Spinbox(bnoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18681  AWGBsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18682  AWGBsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18683  AWGBsbnoise.bind("<Button-5>", onSpinBoxScroll)
18684  AWGBsbnoise.pack(side=LEFT, anchor=W)
18685  AWGBNoiseEntry = Entry(bnoise, width=5, cursor='double_arrow')
18686  AWGBNoiseEntry.bind("<Return>", UpdateAwgContRet)
18687  AWGBNoiseEntry.bind('<MouseWheel>', onAWGBscroll)
18688  AWGBNoiseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18689  AWGBNoiseEntry.bind("<Button-5>", onAWGBscroll)
18690  AWGBNoiseEntry.bind('<Key>', onTextKeyAWG)
18691  AWGBNoiseEntry.pack(side=LEFT, anchor=W)
18692  AWGBNoiseEntry.delete(0,"end")
18693  AWGBNoiseEntry.insert(0,0.0)
18694  #
18695  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
18696  bcompa.pack(side=TOP)
18697  if FWRevOne > 2.16:
18698  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18699  awgsync.pack(side=TOP)
18700  #
18701  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
18702  dismissbutton.pack(side=TOP)
18703  if ShowBallonHelp > 0:
18704  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
18705  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
18706  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
18707  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
18708  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
18709  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
18710  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
18711  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
18712  else:
18713  awgwindow.deiconify()
18714 #
18715 def BAWG2X():
18716  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
18717 
18718  ReMakeAWGwaves()
18719  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
18720  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18721  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18722  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
18723  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18724  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
18725  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
18726  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
18727  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
18728  BisCompA.set(0)
18729  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
18730  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
18731  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18732  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
18733  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
18734  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
18735  BisCompA.set(0)
18736 #
18738  global awgwindow, AWGScreenStatus
18739 
18740  # AWGScreenStatus.set(0)
18741  awgwindow.iconify()
18742 #
18743 # ===== Channel B Mux Mode sub Window =======
18745  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
18746  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
18747  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
18748  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
18749  global CHB_cba, CHB_cbb, CHB_cbc, CHB_cbd
18750  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev, BorderSize
18751  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg
18752  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
18753  global ChopMuxMode, ChopTrig, DualMuxMode, ShowBallonHelp
18754 
18755  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
18756  MuxScreenStatus.set(1)
18757  #
18758  BAWGEnab() # update AWG settings
18759  #
18760  muxwindow = Toplevel()
18761  muxwindow.title("External Mux " + SWRev + RevDate)
18762  muxwindow.resizable(FALSE,FALSE)
18763  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
18764  #
18765  frameM = LabelFrame(muxwindow, text="External Analog Mux", style="A10.TLabelframe") #
18766  frameM.pack(side=LEFT, expand=1, fill=X)
18767  #
18768  # Voltage channel CHB-A
18769  frameA = Frame(frameM)
18770  frameA.pack(side=TOP)
18771  CHB_cba = Checkbutton(frameA, text='CB-A', style="Strace2.TCheckbutton", variable=Show_CBA, command=UpdateTimeTrace)
18772  CHB_cba.pack(side=LEFT, anchor=W)
18773  CHB_Asb = Spinbox(frameA, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18774  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
18775  CHB_Asb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18776  CHB_Asb.bind("<Button-5>", onSpinBoxScroll)
18777  CHB_Asb.pack(side=LEFT)
18778  CHB_Asb.delete(0,"end")
18779  CHB_Asb.insert(0,0.5)
18780  #
18781  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
18782  CHB_Alab.pack(side=LEFT)
18783  CHB_APosEntry = Entry(frameA, width=5, cursor='double_arrow')
18784  CHB_APosEntry.bind('<Return>', onTextKey)
18785  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
18786  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18787  CHB_APosEntry.bind("<Button-5>", onTextScroll)
18788  CHB_APosEntry.bind('<Key>', onTextKey)
18789  CHB_APosEntry.pack(side=LEFT)
18790  CHB_APosEntry.delete(0,"end")
18791  CHB_APosEntry.insert(0,2.5)
18792  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
18793  CHB_Aofflab.pack(side=LEFT)
18794  # Voltage channel CHB-B
18795  frameB = Frame(frameM)
18796  frameB.pack(side=TOP)
18797  CHB_cbb = Checkbutton(frameB, text='CB-B', style="Strace6.TCheckbutton", variable=Show_CBB, command=UpdateTimeTrace)
18798  CHB_cbb.pack(side=LEFT, anchor=W)
18799  CHB_Bsb = Spinbox(frameB, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18800  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
18801  CHB_Bsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18802  CHB_Bsb.bind("<Button-5>", onSpinBoxScroll)
18803  CHB_Bsb.pack(side=LEFT)
18804  CHB_Bsb.delete(0,"end")
18805  CHB_Bsb.insert(0,0.5)
18806  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
18807  CHB_Blab.pack(side=LEFT)
18808  CHB_BPosEntry = Entry(frameB, width=5, cursor='double_arrow')
18809  CHB_BPosEntry.bind('<Return>', onTextKey)
18810  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
18811  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18812  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
18813  CHB_BPosEntry.bind('<Key>', onTextKey)
18814  CHB_BPosEntry.pack(side=LEFT)
18815  CHB_BPosEntry.delete(0,"end")
18816  CHB_BPosEntry.insert(0,2.5)
18817  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
18818  CHB_Bofflab.pack(side=LEFT)
18819  # Voltage channel B-C
18820  frameC = Frame(frameM)
18821  frameC.pack(side=TOP)
18822  CHB_cbc = Checkbutton(frameC, text='CB-C', style="Strace7.TCheckbutton", variable=Show_CBC, command=UpdateTimeTrace)
18823  CHB_cbc.pack(side=LEFT, anchor=W)
18824  CHB_Csb = Spinbox(frameC, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18825  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
18826  CHB_Csb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18827  CHB_Csb.bind("<Button-5>", onSpinBoxScroll)
18828  CHB_Csb.pack(side=LEFT)
18829  CHB_Csb.delete(0,"end")
18830  CHB_Csb.insert(0,0.5)
18831  #
18832  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
18833  CHB_Clab.pack(side=LEFT)
18834  CHB_CPosEntry = Entry(frameC, width=5, cursor='double_arrow')
18835  CHB_CPosEntry.bind('<Return>', onTextKey)
18836  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
18837  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18838  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
18839  CHB_CPosEntry.bind('<Key>', onTextKey)
18840  CHB_CPosEntry.pack(side=LEFT)
18841  CHB_CPosEntry.delete(0,"end")
18842  CHB_CPosEntry.insert(0,2.5)
18843  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
18844  CHB_Cofflab.pack(side=LEFT)
18845  # Voltage channel B-D
18846  frameD = Frame(frameM)
18847  frameD.pack(side=TOP)
18848  CHB_cbd = Checkbutton(frameD, text='CB-D', style="Strace4.TCheckbutton", variable=Show_CBD, command=UpdateTimeTrace)
18849  CHB_cbd.pack(side=LEFT, anchor=W)
18850  CHB_Dsb = Spinbox(frameD, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18851  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
18852  CHB_Dsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18853  CHB_Dsb.bind("<Button-5>", onSpinBoxScroll)
18854  CHB_Dsb.pack(side=LEFT)
18855  CHB_Dsb.delete(0,"end")
18856  CHB_Dsb.insert(0,0.5)
18857  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
18858  CHB_Dlab.pack(side=LEFT)
18859  CHB_DPosEntry = Entry(frameD, width=5, cursor='double_arrow')
18860  CHB_DPosEntry.bind('<Return>', onTextKey)
18861  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
18862  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18863  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
18864  CHB_DPosEntry.bind('<Key>', onTextKey)
18865  CHB_DPosEntry.pack(side=LEFT)
18866  CHB_DPosEntry.delete(0,"end")
18867  CHB_DPosEntry.insert(0,2.5)
18868  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
18869  CHB_Dofflab.pack(side=LEFT)
18870  #
18871  frameR = Frame(frameM)
18872  frameR.pack(side=TOP)
18873  RefTraceMenu = Menubutton(frameR, text="Reference Traces", width=17, style="W17.TButton")
18874  RefTraceMenu.menu = Menu(RefTraceMenu, tearoff = 0 )
18875  RefTraceMenu["menu"] = RefTraceMenu.menu
18876  RefTraceMenu.menu.add_command(label="-Take Snap Shot", command=BSnapShot)
18877  RefTraceMenu.menu.add_command(label="-Ref MUX trace-", foreground="blue", command=donothing)
18878  RefTraceMenu.menu.add_checkbutton(label='RMuxA', background=COLORtraceR2, variable=ShowRMA, command=UpdateTimeTrace)
18879  RefTraceMenu.menu.add_checkbutton(label='RMuxB', background=COLORtraceR6, variable=ShowRMB, command=UpdateTimeTrace)
18880  RefTraceMenu.menu.add_checkbutton(label='RMuxC', background=COLORtraceR7, variable=ShowRMC, command=UpdateTimeTrace)
18881  RefTraceMenu.menu.add_checkbutton(label='RMuxD', background=COLORtraceR4, variable=ShowRMD, command=UpdateTimeTrace)
18882  RefTraceMenu.pack(side=LEFT)
18883  #
18884  frameE = Frame(frameM)
18885  frameE.pack(side=TOP)
18886  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
18887  muxenab.pack(side=LEFT)
18888  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
18889  SyncButton.pack(side=LEFT)
18890  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
18891  dismissbutton.pack(side=LEFT)
18892  frameF = Frame(frameM)
18893  frameF.pack(side=TOP)
18894  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
18895  dmx.pack(side=LEFT)
18896  frameCH = Frame(frameM)
18897  frameCH.pack(side=TOP)
18898  altmx = Radiobutton(frameCH, text='Alternate Sweep', variable=ChopMuxMode, value=0, command=SetChopMuxMode)
18899  altmx.pack(side=LEFT)
18900  chopmx = Radiobutton(frameCH, text='Chop Sweep', variable=ChopMuxMode, value=1, command=SetChopMuxMode)
18901  chopmx.pack(side=LEFT)
18902  frameCT = Frame(frameM)
18903  frameCT.pack(side=TOP)
18904  # Chope Mode trigger drop-down
18905  ChopTrigMenu = Menubutton(frameCT, text="Chop Mode Trigger", width=17, style="W17.TButton")
18906  ChopTrigMenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18907  ChopTrigMenu["menu"] = ChopTrigMenu.menu
18908  ChopTrigMenu.menu.add_command(label="-MUX Chan-", foreground="blue", command=donothing)
18909  ChopTrigMenu.menu.add_radiobutton(label="None", variable=ChopTrig, value=0) #, command=BAWGBModeLabel)
18910  ChopTrigMenu.menu.add_radiobutton(label="Mux A", variable=ChopTrig, value=1) #, command=BAWGBModeLabel)
18911  ChopTrigMenu.menu.add_radiobutton(label="Mux B", variable=ChopTrig, value=2) #, command=BAWGBModeLabel)
18912  ChopTrigMenu.menu.add_radiobutton(label="Mux C", variable=ChopTrig, value=3) #, command=BAWGBModeLabel)
18913  ChopTrigMenu.menu.add_radiobutton(label="Mux D", variable=ChopTrig, value=4) #, command=BAWGBModeLabel)
18914  ChopTrigMenu.pack(side=LEFT)
18915  #
18916  SaveMuxmenu = Menubutton(frameCT, text="Export csv", width=10, style="W17.TButton")
18917  SaveMuxmenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18918  SaveMuxmenu["menu"] = SaveMuxmenu.menu
18919  SaveMuxmenu.menu.add_command(label="Save Mux traces", command=BSaveMuxData)
18920  SaveMuxmenu.menu.add_command(label="Save single channel", command=BSaveChannelData)
18921  SaveMuxmenu.pack(side=LEFT)
18922  # Gray out main Channel B controls
18923  CHBlab.config(style="SGray.TButton")
18924  CHBofflab.config(style="SGray.TButton")
18925 
18926  #
18927  if ShowBallonHelp > 0:
18928  CHB_Alab_tip = CreateToolTip(CHB_Alab, 'Select CB-A vertical range/position axis to be used for markers and drawn color')
18929  CHB_Blab_tip = CreateToolTip(CHB_Blab, 'Select CB-B vertical range/position axis to be used for markers and drawn color')
18930  CHB_Clab_tip = CreateToolTip(CHB_Clab, 'Select CB-C vertical range/position axis to be used for markers and drawn color')
18931  CHB_Dlab_tip = CreateToolTip(CHB_Dlab, 'Select CB-D vertical range/position axis to be used for markers and drawn color')
18932  CHB_Aofflab_tip = CreateToolTip(CHB_Aofflab, 'Set CB-A position to DC average of signal')
18933  CHB_Bofflab_tip = CreateToolTip(CHB_Bofflab, 'Set CB-B position to DC average of signal')
18934  CHB_Cofflab_tip = CreateToolTip(CHB_Cofflab, 'Set CB-C position to DC average of signal')
18935  CHB_Dofflab_tip = CreateToolTip(CHB_Dofflab, 'Set CB-D position to DC average of signal')
18936  ChopTrigMenu_tip = CreateToolTip(ChopTrigMenu, 'Menu to Select Trigger Source')
18937  RefTraceMenu_tip = CreateToolTip(RefTraceMenu, 'Menu to Select Mux Reference Traces')
18938  SaveMuxmenu_tip = CreateToolTip(SaveMuxmenu, 'Menu to Export Mux Trace Data to .csv file')
18939 #
18941  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
18942  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab, CHB_cbc, CHB_cbd
18943 
18944  if DualMuxMode.get() == 1:
18945  AWGAIOMode.set(1) # force awg A split I/O mode
18946  AWGBIOMode.set(1) # force awg B split I/O mode
18947  ShowC1_V.set(0) # force A voltage trace off
18948  CHB_cbc.config(text="CA-C")
18949  CHB_cbd.config(text="CA-D")
18950  CHB_Clab.config(text="CA-C V/Div")
18951  CHB_Dlab.config(text="CA-D V/Div")
18952  CHB_Cofflab.config(text="CA-C Pos")
18953  CHB_Dofflab.config(text="CA-D Pos")
18954  BAWGEnab() # update AWG settings
18955  # Gray out main Channel A controls
18956  CHAlab.config(style="SGray.TButton")
18957  CHAofflab.config(style="SGray.TButton")
18958  else:
18959  ShowC1_V.set(1) # force A voltage trace on
18960  CHB_cbc.config(text="CB-C")
18961  CHB_cbd.config(text="CB-D")
18962  CHB_Clab.config(text="CB-C V/Div")
18963  CHB_Dlab.config(text="CB-D V/Div")
18964  CHB_Cofflab.config(text="CB-C Pos")
18965  CHB_Dofflab.config(text="CB-D Pos")
18966  # Reset main Channel A control colors
18967  CHAlab.config(style="Rtrace1.TButton")
18968  CHAofflab.config(style="Rtrace1.TButton")
18969 #
18971  global ChopMuxMode, AWGAIOMode, AWGBIOMode, AWGAMode, AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry
18972  global AWGAPhaseEntry, SAMPLErate, ShowC1_V, ShowC2_V, TgInput
18973 
18974  if ChopMuxMode.get() > 0: # set AWG A to a square wave at 25 KHz 0.5 to 4.5 V, mode = SVMI_SPLIT
18975  AWGAIOMode.set(1) # force awg A split I/O mode
18976  AWGAMode.set(0) # force awg A mode to SVMI
18977  BAWGAModeLabel()
18978  AWGAShape.set(4) # force awg A to square shape
18979  AWGAAmplEntry.delete(0,"end")
18980  AWGAAmplEntry.insert(0,0.5) # force awg A Min value to 0.5 V
18981  AWGAOffsetEntry.delete(0,"end")
18982  AWGAOffsetEntry.insert(0,4.5) # force awg A Max value to 4.5 V
18983  AWGAFreqEntry.delete(0,"end")
18984  AWGAFreqEntry.insert(0,SAMPLErate/4) # force awg A Freg value to 25000 (1/4 base sample rate)
18985  AWGAPhaseEntry.delete(0,"end")
18986  AWGAPhaseEntry.insert(0,0) # force awg A Phase value to 0
18987  ReMakeAWGwaves()
18988  AWGBIOMode.set(1) # force awg A split I/O mode
18989  BAWGBModeLabel()
18990  ShowC1_V.set(0) # force A voltage trace off
18991  ShowC2_V.set(0) # force B voltage trace off
18992  TgInput.set(0) # force main Trigger source to none
18993  CHAlab.config(style="SGray.TButton")
18994  CHAofflab.config(style="SGray.TButton")
18995  else:
18996  CHAlab.config(style="Rtrace1.TButton")
18997  CHAofflab.config(style="Rtrace1.TButton")
18998 
19000  global MuxSync, hipulseimg, lowpulseimg, SyncButton
19001 
19002  if MuxSync.get() == 0:
19003  SyncButton.config(image=hipulseimg)
19004  else:
19005  SyncButton.config(image=lowpulseimg)
19006 
19008  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
19009  global ChopTrig, ChopMuxMode, MarkerScale
19010 
19011  MuxScreenStatus.set(0)
19012  awgsync.config(state=NORMAL)
19013  ChopMuxMode.set(0)
19014  ChopTrig.set(0)
19015  MarkerScale.set(0)
19016  # Reset main Channel B control colors
19017  CHBlab.config(style="Rtrace2.TButton")
19018  CHBofflab.config(style="Rtrace2.TButton")
19019  CHAlab.config(style="Rtrace1.TButton")
19020  CHAofflab.config(style="Rtrace1.TButton")
19021  muxwindow.destroy()
19022 #
19023 def BodeCaresize(event):
19024  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
19025 
19026  CANVASwidthBP = event.width - 4
19027  CANVASheightBP = event.height - 4
19028  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
19029  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
19030  UpdateBodeAll()
19031 #
19033  global FStepSync, DevOne
19034 
19035  if FStepSync.get() == 0:
19036  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
19037  elif FStepSync.get() == 1:
19038  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
19039  elif FStepSync.get() == 2:
19040  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
19041 #
19043  global FSweepSync, DevOne
19044 
19045  if FSweepSync.get() == 0:
19046  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
19047  elif FSweepSync.get() == 1:
19048  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
19049  elif FSweepSync.get() == 2:
19050  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
19051 #
19053  global BDSweepFile, FileSweepFreq, FileSweepAmpl
19054 
19055  if BDSweepFile.get() > 0:
19056  # Read values from CVS file
19057  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
19058  try:
19059  CSVFile = open(filename)
19060  csv_f = csv.reader(CSVFile)
19061  FileSweepFreq = []
19062  FileSweepAmpl = []
19063  for row in csv_f:
19064  try:
19065  FileSweepFreq.append(float(row[0]))
19066  FileSweepAmpl.append(float(row[1]))
19067  except:
19068  print( 'skipping non-numeric row')
19069  FileSweepFreq = numpy.array(FileSweepFreq)
19070  FileSweepAmpl = numpy.array(FileSweepAmpl)
19071  MaxAmpl = numpy.amax(FileSweepAmpl)
19072  NormAmpl = MaxAmpl
19073  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
19074  if (s == None): # If Cancel pressed, then None
19075  return()
19076  try: # Error if for example no numeric characters or OK pressed without input (s = "")
19077  v = int(s)
19078  except:
19079  s = "error"
19080 
19081  if s != "error":
19082  NormAmpl = MaxAmpl - v
19083  else:
19084  NormAmpl = MaxAmpl
19085  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
19086  CSVFile.close()
19087  StopBodeEntry.delete(0,"end")
19088  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
19089  StartBodeEntry.delete(0,"end")
19090  StartBodeEntry.insert(0,FileSweepFreq[0])
19091  SweepStepBodeEntry.delete(0,"end")
19092  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
19093  except:
19094  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
19095 #
19096 # ========== Make Bode Plot Window =============
19098  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
19099  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
19100  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
19101  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
19102  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
19103  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
19104  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
19105  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
19106  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
19107  global FrameRefief, BorderSize, LocalLanguage
19108  global sbode_tip, rbode_tip, bd3_tip, bd4_tip, bd5_tip, bd6_tip, bd7_tip, bd8_tip, bodismiss1button_tip
19109  global bstopfreqlab, bstartfreqlab, ImCenlab, BPhCenlab
19110 
19111  if BodeScreenStatus.get() == 0:
19112  BodeScreenStatus.set(1)
19113  BodeDisp.set(1)
19114  BodeCheckBox()
19115  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
19116  CANVASheightBP = GRHBP + 80 # The ode canvas height
19117  CutDC.set(1) # set to remove DC
19118  AWGAMode.set(0) # Set AWG A to SVMI
19119  AWGAShape.set(1) # Set Shape to Sine
19120  AWGBMode.set(2) # Set AWG B to Hi-Z
19121  bodewindow = Toplevel()
19122  bodewindow.title("Bode Plotter " + SWRev + RevDate)
19123  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
19124  frame2bp = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19125  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
19126 
19127  frame2b = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19128  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
19129 
19130  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
19131  Bodeca.bind('<Configure>', BodeCaresize)
19132  Bodeca.bind('<1>', onCanvasBodeLeftClick)
19133  Bodeca.bind('<3>', onCanvasBodeRightClick)
19134  Bodeca.bind("<Up>", onCanvasUpArrow)
19135  Bodeca.bind("<Down>", onCanvasDownArrow)
19136  Bodeca.bind("<Left>", onCanvasLeftArrow)
19137  Bodeca.bind("<Right>", onCanvasRightArrow)
19138  Bodeca.bind("<space>", onCanvasSpaceBar)
19139  Bodeca.bind("1", onCanvasBdOne)
19140  Bodeca.bind("2", onCanvasBdTwo)
19141  Bodeca.bind("3", onCanvasBdThree)
19142  Bodeca.bind("4", onCanvasBdFour)
19143  Bodeca.bind("5", onCanvasBdFive)
19144  Bodeca.bind("6", onCanvasBdSix)
19145  Bodeca.bind("7", onCanvasBdSeven)
19146  Bodeca.bind("8", onCanvasBdEight)
19147  Bodeca.bind("9", onCanvasBdNine)
19148  Bodeca.bind("0", onCanvasBdZero)
19149  Bodeca.bind("f", onCanvasShowBPcur)
19150  Bodeca.bind("d", onCanvasShowBdBcur)
19151  Bodeca.bind("h", onCanvasShowPdBcur)
19152  Bodeca.bind("s", onCanvasBdSnap)
19153  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
19154 
19155  # right side drop down menu buttons
19156  dropmenu = Frame( frame2bp )
19157  dropmenu.pack(side=TOP)
19158  # File menu
19159  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19160  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
19161  BodeFilemenu["menu"] = BodeFilemenu.menu
19162  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
19163  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
19164  BodeFilemenu.menu.add_command(label="Run Script", command=RunScript)
19165  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
19166  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
19167  BodeFilemenu.pack(side=LEFT, anchor=W)
19168  #
19169  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19170  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
19171  BodeOptionmenu["menu"] = BodeOptionmenu.menu
19172  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19173  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
19174  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19175  BodeOptionmenu.menu.add_command(label="Store trace (s)", command=BSTOREtraceBP)
19176  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19177  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19178  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
19179  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
19180  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
19181  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
19182  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
19183  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
19184  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
19185  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
19186  BodeOptionmenu.pack(side=LEFT, anchor=W)
19187  #
19188  RUNframe = Frame( frame2bp )
19189  RUNframe.pack(side=TOP)
19190  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
19191  rbode.pack(side=LEFT)
19192  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
19193  sbode.pack(side=LEFT)
19194  #
19195  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
19196  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
19197  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
19198  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19199  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19200  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19201  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19202  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19203  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19204  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19205  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19206  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19207  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19208  BodeFFTwindmenu.pack(side=TOP)
19209  #
19210  tracemenu = Frame( frame2bp )
19211  tracemenu.pack(side=TOP)
19212  # Curves menu
19213  # Show channels menu
19214  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
19215  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
19216  BodeShowmenu["menu"] = BodeShowmenu.menu
19217  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
19218  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
19219  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
19220  BodeShowmenu.menu.add_checkbutton(label='CA-dBV (1)', variable=ShowCA_VdB, command=UpdateBodeAll)
19221  BodeShowmenu.menu.add_checkbutton(label='CB-dBV (2)', variable=ShowCB_VdB, command=UpdateBodeAll)
19222  BodeShowmenu.menu.add_checkbutton(label='Phase A-B (3)', variable=ShowCA_P, command=UpdateBodeAll)
19223  BodeShowmenu.menu.add_checkbutton(label='Phase B-A (4)', variable=ShowCB_P, command=UpdateBodeAll)
19224  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
19225  BodeShowmenu.menu.add_radiobutton(label='None (0)', variable=ShowMathBP, value=0, command=UpdateBodeAll)
19226  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB (9)', variable=ShowMathBP, value=1, command=UpdateBodeAll)
19227  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB (8)', variable=ShowMathBP, value=2, command=UpdateBodeAll)
19228  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
19229  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
19230  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
19231  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
19232  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
19233  BodeShowmenu.menu.add_separator()
19234  BodeShowmenu.menu.add_checkbutton(label='RA-dBV (6)', variable=ShowCA_RdB, command=UpdateBodeAll)
19235  BodeShowmenu.menu.add_checkbutton(label='RB-dBV (7)', variable=ShowCB_RdB, command=UpdateBodeAll)
19236  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
19237  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
19238  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
19239  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
19240  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
19241  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
19242  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
19243  BodeShowmenu.pack(side=LEFT, anchor=W)
19244  #
19245  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
19246  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
19247  BodeMarkmenu["menu"] = BodeMarkmenu.menu
19248  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
19249  BodeMarkmenu.menu.add_checkbutton(label='Marker (5)', variable=ShowMarkerBP, command=UpdateBodeAll)
19250  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
19251  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
19252  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
19253  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor (d)', variable=ShowBdBCur, value=1)
19254  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor (h)', variable=ShowBdBCur, value=2)
19255  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor (f)', variable=ShowBPCur)
19256  BodeMarkmenu.pack(side=LEFT, anchor=W)
19257  #
19258  # Horz Scale
19259  HzScale = Frame( frame2bp )
19260  HzScale.pack(side=TOP)
19261  brb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
19262  brb1.pack(side=LEFT)
19263  brb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
19264  brb2.pack(side=LEFT)
19265 
19266  DBrange = Frame( frame2bp )
19267  DBrange.pack(side=TOP)
19268  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
19269  bd3.pack(side=LEFT)
19270  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
19271  bd4.pack(side=LEFT)
19272 
19273  LVBrange = Frame( frame2bp )
19274  LVBrange.pack(side=TOP)
19275  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
19276  bd5.pack(side=LEFT)
19277  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
19278  bd6.pack(side=LEFT)
19279 
19280  LVSrange = Frame( frame2bp )
19281  LVSrange.pack(side=TOP)
19282  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
19283  bd7.pack(side=LEFT)
19284  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
19285  bd8.pack(side=LEFT)
19286 
19287  PhaseCenter = Frame( frame2bp )
19288  PhaseCenter.pack(side=TOP)
19289  BPhCenlab = Label(PhaseCenter, text="Center Phase on")
19290  BPhCenlab.pack(side=LEFT)
19291  PhCenBodeEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19292  PhCenBodeEntry.bind('<Return>', onTextKey)
19293  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19294  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19295  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
19296  PhCenBodeEntry.bind('<Key>', onTextKey)
19297  PhCenBodeEntry.pack(side=LEFT)
19298  PhCenBodeEntry.delete(0,"end")
19299  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
19300  #
19301  ImpedCenter = Frame( frame2bp )
19302  ImpedCenter.pack(side=TOP)
19303  ImCenlab = Label(ImpedCenter, text="Center Imped on")
19304  ImCenlab.pack(side=LEFT)
19305  ImCenBodeEntry = Entry(ImpedCenter, width=5, cursor='double_arrow')
19306  ImCenBodeEntry.bind('<Return>', onTextKey)
19307  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19308  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19309  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
19310  ImCenBodeEntry.bind('<Key>', onTextKey)
19311  ImCenBodeEntry.pack(side=LEFT)
19312  ImCenBodeEntry.delete(0,"end")
19313  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
19314  # sweep generator mode menu buttons
19315  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
19316  FSweepmenu.pack(side=TOP)
19317 
19318  Frange1 = Frame( frame2bp )
19319  Frange1.pack(side=TOP)
19320  bstartfreqlab = Label(Frange1, text="Start Freq")
19321  bstartfreqlab.pack(side=LEFT)
19322  StartBodeEntry = Entry(Frange1, width=5, cursor='double_arrow')
19323  StartBodeEntry.bind('<Return>', onTextKey)
19324  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
19325  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19326  StartBodeEntry.bind("<Button-5>", onTextScroll)
19327  StartBodeEntry.bind('<Key>', onTextKey)
19328  StartBodeEntry.pack(side=LEFT)
19329  StartBodeEntry.delete(0,"end")
19330  StartBodeEntry.insert(0,10)
19331 
19332  Frange2 = Frame( frame2bp )
19333  Frange2.pack(side=TOP)
19334  bstopfreqlab = Label(Frange2, text="Stop Freq")
19335  bstopfreqlab.pack(side=LEFT)
19336  StopBodeEntry = Entry(Frange2, width=5, cursor='double_arrow')
19337  StopBodeEntry.bind('<Return>', onTextKey)
19338  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
19339  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19340  StopBodeEntry.bind("<Button-5>", onTextScroll)
19341  StopBodeEntry.bind('<Key>', onTextKey)
19342  StopBodeEntry.pack(side=LEFT)
19343  StopBodeEntry.delete(0,"end")
19344  StopBodeEntry.insert(0,10000)
19345 
19346  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
19347  sgrb1.pack(side=TOP)
19348  Frange4 = Frame( frame2bp )
19349  Frange4.pack(side=TOP)
19350  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
19351  sgrb2.pack(side=LEFT)
19352  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
19353  sgrb3.pack(side=LEFT)
19354  if MinigenScreenStatus.get() > 0:
19355  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
19356  sgrb1.pack(side=TOP)
19357  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
19358  ffcb.pack(side=TOP)
19359  Frange3 = Frame( frame2bp )
19360  Frange3.pack(side=TOP)
19361  sweepsteplab = Label(Frange3, text="Sweep Steps")
19362  sweepsteplab.pack(side=LEFT)
19363  SweepStepBodeEntry = Entry(Frange3, width=5, cursor='double_arrow')
19364  SweepStepBodeEntry.bind('<Return>', onTextKey)
19365  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
19366  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19367  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
19368  SweepStepBodeEntry.bind('<Key>', onTextKey)
19369  SweepStepBodeEntry.pack(side=LEFT)
19370  SweepStepBodeEntry.delete(0,"end")
19371  SweepStepBodeEntry.insert(0,100)
19372 
19373  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
19374  sgrb5.pack(side=TOP)
19375  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
19376  sgrb6.pack(side=TOP)
19377  Plotsframe = Frame( frame2bp )
19378  Plotsframe.pack(side=TOP)
19379  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
19380  nyquistplotbutton.pack(side=LEFT)
19381  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
19382  nicholsplotbutton.pack(side=LEFT)
19383  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
19384  bodismiss1button.pack(side=TOP)
19385 
19386  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19387  ADI2.pack(side=TOP)
19388  if ShowBallonHelp > 0:
19389  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
19390  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
19391  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
19392  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
19393  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
19394  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
19395  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
19396  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
19397  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
19398  if LocalLanguage != "English":
19399  BLoadConfig(LocalLanguage) # load local language configuration
19400 #
19402  global bodewindow, BodeScreenStatus, ca, FSweepMode
19403 
19404  BodeScreenStatus.set(0)
19405  FSweepMode.set(0)
19406  BodeDisp.set(0)
19407  BodeCheckBox()
19408  bodewindow.destroy()
19409  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19410 #
19411 def FreqCaresize(event):
19412  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
19413 
19414  CANVASwidthF = event.width - 4
19415  CANVASheightF = event.height - 4
19416  GRWF = CANVASwidthF - 10 - (2 * X0LF) # new grid width
19417  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
19418  UpdateFreqAll()
19419 #
19420 # ================ Make spectrum sub window ==========================
19422  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
19423  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp, ShowAWGASA
19424  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA, ShowAWGBSA
19425  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate, AWGShowAdvanced
19426  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
19427  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
19428  global FrameRefief, BorderSize, LocalLanguage, SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry
19429  global sb_tip, rb_tip, bless_tip, bmore_tip, b3_tip, b4_tip, b5_tip, b6_tip, b7_tip, b8_tip, sadismiss1button_tip
19430  global SAMagdiv, SAVScale, SAvertmaxEntry, SAvertminEntry, SAVPSD
19431 
19432  if SpectrumScreenStatus.get() == 0:
19433  SpectrumScreenStatus.set(1)
19434  FreqDisp.set(1)
19435  FreqCheckBox()
19436  CANVASwidthF = GRWF + 10 + 2 * X0LF # The spectrum canvas width
19437  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
19438  freqwindow = Toplevel()
19439  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
19440  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
19441  frame2fr = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19442  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
19443 
19444  frame2f = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19445  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
19446 
19447  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
19448  Freqca.bind('<Configure>', FreqCaresize)
19449  Freqca.bind('<1>', onCanvasFreqLeftClick)
19450  Freqca.bind('<3>', onCanvasFreqRightClick)
19451  Freqca.bind("<Up>", onCanvasUpArrow)
19452  Freqca.bind("<Down>", onCanvasDownArrow)
19453  Freqca.bind("<Left>", onCanvasLeftArrow)
19454  Freqca.bind("<Right>", onCanvasRightArrow)
19455  Freqca.bind("<space>", onCanvasSpaceBar)
19456  Freqca.bind("1", onCanvasSAOne)
19457  Freqca.bind("2", onCanvasSATwo)
19458  Freqca.bind("3", onCanvasSAThree)
19459  Freqca.bind("4", onCanvasSAFour)
19460  Freqca.bind("5", onCanvasSAFive)
19461  Freqca.bind("6", onCanvasSASix)
19462  Freqca.bind("7", onCanvasSASeven)
19463  Freqca.bind("8", onCanvasSAEight)
19464  Freqca.bind("9", onCanvasSANine)
19465  Freqca.bind("0", onCanvasSAZero)
19466  Freqca.bind("a", onCanvasSAAverage)
19467  Freqca.bind("n", onCanvasSANormal)
19468  Freqca.bind("p", onCanvasSAPeak)
19469  Freqca.bind("r", onCanvasSAReset)
19470  Freqca.bind("f", onCanvasShowFcur)
19471  Freqca.bind("d", onCanvasShowdBcur)
19472  Freqca.bind("h", onCanvasShowPcur)
19473  Freqca.bind("s", onCanvasSASnap)
19474  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
19475  # right side drop down menu buttons
19476  dropmenu = Frame( frame2fr )
19477  dropmenu.pack(side=TOP)
19478  # File menu
19479  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19480  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
19481  SAFilemenu["menu"] = SAFilemenu.menu
19482  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
19483  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
19484  SAFilemenu.menu.add_command(label="Run Script", command=RunScript)
19485  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
19486  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
19487  SAFilemenu.pack(side=LEFT, anchor=W)
19488  #
19489  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19490  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
19491  SAOptionmenu["menu"] = SAOptionmenu.menu
19492  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19493  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
19494  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
19495  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19496  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
19497  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19498  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19499  SAOptionmenu.pack(side=LEFT, anchor=W)
19500  #
19501  RUNframe = Frame( frame2fr )
19502  RUNframe.pack(side=TOP)
19503  sarb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
19504  sarb.pack(side=LEFT)
19505  sasb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
19506  sasb.pack(side=LEFT)
19507  #
19508  Modeframe = Frame( frame2fr )
19509  Modeframe.pack(side=TOP)
19510  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
19511  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
19512  Modemenu["menu"] = Modemenu.menu
19513  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
19514  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
19515  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
19516  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
19517  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
19518  Modemenu.pack(side=LEFT)
19519  #
19520  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
19521  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
19522  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
19523  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19524  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19525  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19526  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19527  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19528  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19529  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19530  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19531  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19532  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19533  SAFFTwindmenu.pack(side=LEFT)
19534  #
19535  SamplesMenu = Frame( frame2fr )
19536  SamplesMenu.pack(side=TOP)
19537  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
19538  bless.pack(side=LEFT)
19539  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
19540  bmore.pack(side=LEFT)
19541  #
19542  # Show channels menu
19543  #
19544  MarkersMenu = Frame( frame2fr )
19545  MarkersMenu.pack(side=TOP)
19546  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
19547  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
19548  SAShowmenu["menu"] = SAShowmenu.menu
19549  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
19550  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
19551  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
19552  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
19553  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
19554  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
19555  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
19556  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
19557  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
19558  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
19559  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
19560  if AWGShowAdvanced.get() > 0:
19561  SAShowmenu.menu.add_command(label="-AWG-", command=donothing)
19562  SAShowmenu.menu.add_checkbutton(label='AWG A', variable=ShowAWGASA, command=UpdateFreqAll)
19563  SAShowmenu.menu.add_checkbutton(label='AWG B', variable=ShowAWGBSA, command=UpdateFreqAll)
19564  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
19565  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
19566  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
19567  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
19568  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
19569  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
19570  SAShowmenu.pack(side=LEFT)
19571  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
19572  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
19573  SACursormenu["menu"] = SACursormenu.menu
19574  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
19575  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
19576  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
19577  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
19578  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
19579  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
19580  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
19581  #SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
19582  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
19583  SACursormenu.pack(side=LEFT)
19584  # HScale
19585  Frange1 = Frame( frame2fr )
19586  Frange1.pack(side=TOP)
19587  startfreqlab = Label(Frange1, text="Startfreq")
19588  startfreqlab.pack(side=LEFT)
19589  StartFreqEntry = Entry(Frange1, width=5, cursor='double_arrow')
19590  StartFreqEntry.bind('<Return>', onTextKey)
19591  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
19592  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19593  StartFreqEntry.bind("<Button-5>", onTextScroll)
19594  StartFreqEntry.bind('<Key>', onTextKey)
19595  StartFreqEntry.pack(side=LEFT)
19596  StartFreqEntry.delete(0,"end")
19597  StartFreqEntry.insert(0,10)
19598 
19599  Frange2 = Frame( frame2fr )
19600  Frange2.pack(side=TOP)
19601  stopfreqlab = Label(Frange2, text="Stopfreq")
19602  stopfreqlab.pack(side=LEFT)
19603  StopFreqEntry = Entry(Frange2, width=7, cursor='double_arrow')
19604  StopFreqEntry.bind('<Return>', onTextKey)
19605  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
19606  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
19607  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
19608  StopFreqEntry.bind('<Key>', onTextKey)
19609  StopFreqEntry.pack(side=LEFT)
19610  StopFreqEntry.delete(0,"end")
19611  StopFreqEntry.insert(0,10000)
19612 
19613  HzScale = Frame( frame2fr )
19614  HzScale.pack(side=TOP)
19615  sarb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
19616  sarb1.pack(side=LEFT)
19617  sarb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
19618  sarb2.pack(side=LEFT)
19619  #
19620  PhaseCenter = Frame( frame2fr )
19621  PhaseCenter.pack(side=TOP)
19622  PhCenlab = Label(PhaseCenter, text="Center Phase on")
19623  PhCenlab.pack(side=LEFT)
19624  PhCenFreqEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19625  PhCenFreqEntry.bind('<Return>', onTextKey)
19626  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
19627  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19628  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
19629  PhCenFreqEntry.bind('<Key>', onTextKey)
19630  PhCenFreqEntry.pack(side=LEFT)
19631  PhCenFreqEntry.delete(0,"end")
19632  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
19633  #
19634  vertlabel = Label( frame2fr, text="Vertical Scale" )
19635  vertlabel.pack(side=TOP)
19636  savrb0 = Radiobutton(frame2fr, text="In dB", variable=SAVScale, value=0, command=UpdateFreqTrace )
19637  savrb0.pack(side=TOP)
19638  #
19639  DBrange = Frame( frame2fr )
19640  DBrange.pack(side=TOP)
19641  sab3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
19642  sab3.pack(side=LEFT)
19643  sab4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
19644  sab4.pack(side=LEFT)
19645 
19646  LVBrange = Frame( frame2fr )
19647  LVBrange.pack(side=TOP)
19648  sab5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
19649  sab5.pack(side=LEFT)
19650  sab6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
19651  sab6.pack(side=LEFT)
19652 
19653  LVSrange = Frame( frame2fr )
19654  LVSrange.pack(side=TOP)
19655  sab7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
19656  sab7.pack(side=LEFT)
19657  sab8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
19658  sab8.pack(side=LEFT)
19659  # Add RMS V controls
19660  vertscale = Frame( frame2fr )
19661  vertscale.pack(side=TOP)
19662  savlab1 = Label(vertscale, text="V RMS")
19663  savlab1.pack(side=LEFT)
19664  savrb1 = Radiobutton(vertscale, text="Lin", variable=SAVScale, value=1, command=UpdateFreqTrace )
19665  savrb1.pack(side=LEFT)
19666  savrb2 = Radiobutton(vertscale, text="Log", variable=SAVScale, value=2, command=UpdateFreqTrace )
19667  savrb2.pack(side=LEFT)
19668  sapsdcb = Checkbutton(frame2fr, text="PSD (sqrt Hz)", variable=SAVPSD)
19669  sapsdcb.pack(side=TOP)
19670  #
19671  vertmax = Frame( frame2fr )
19672  vertmax.pack(side=TOP)
19673  vertmaxlab = Label(vertmax, text="VRMS Max")
19674  vertmaxlab.pack(side=LEFT)
19675  SAvertmaxEntry = Spinbox(vertmax, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19676  SAvertmaxEntry.bind('<MouseWheel>', onSpinBoxScroll)
19677  SAvertmaxEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19678  SAvertmaxEntry.bind("<Button-5>", onSpinBoxScroll)
19679  SAvertmaxEntry.delete(0,"end")
19680  SAvertmaxEntry.insert(0,"1.0")
19681  SAvertmaxEntry.pack(side=LEFT)
19682 
19692  vertmin = Frame( frame2fr )
19693  vertmin.pack(side=TOP)
19694  vertminlab = Label(vertmin, text="VRMS Min")
19695  vertminlab.pack(side=LEFT)
19696  SAvertminEntry = Spinbox(vertmin, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19697  SAvertminEntry.bind('<MouseWheel>', onSpinBoxScroll)
19698  SAvertminEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19699  SAvertminEntry.bind("<Button-5>", onSpinBoxScroll)
19700  SAvertminEntry.pack(side=LEFT)
19701  SAvertminEntry.delete(0,"end")
19702  SAvertminEntry.insert(0,"100uV")
19703 
19713  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
19714  sadismiss1button.pack(side=TOP)
19715 
19716  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19717  ADI2.pack(side=TOP)
19718  if ShowBallonHelp > 0:
19719  sb_tip = CreateToolTip(sasb, 'Stop acquiring data')
19720  rb_tip = CreateToolTip(sarb, 'Start acquiring data')
19721  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
19722  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
19723  b3_tip = CreateToolTip(sab3, 'Increase number of dB/Div')
19724  b4_tip = CreateToolTip(sab4, 'Decrease number of dB/Div')
19725  b5_tip = CreateToolTip(sab5, 'Increase Ref Level by 10 dB')
19726  b6_tip = CreateToolTip(sab6, 'Decrease Ref Level by 10 dB')
19727  b7_tip = CreateToolTip(sab7, 'Increase Ref Level by 1 dB')
19728  b8_tip = CreateToolTip(sab8, 'Decrease Ref Level by 1 dB')
19729  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
19730  if LocalLanguage != "English":
19731  BLoadConfig(LocalLanguage) # load local language configuration
19732 
19734  global freqwindow, SpectrumScreenStatus, ca
19735 
19736  SpectrumScreenStatus.set(0)
19737  FreqDisp.set(0)
19738  FreqCheckBox()
19739  freqwindow.destroy()
19740  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19741 #
19742 def XYcaresize(event):
19743  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
19744  global YminXY, YmaxXY, XminXY, XmaxXY
19745 
19746  XOLXY = FontSize * 7
19747  CANVASwidthXY = event.width - 4
19748  CANVASheightXY = event.height - 4
19749  GRWXY = CANVASwidthXY - (2*X0LXY) # 18 new grid width
19750  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
19751  YminXY = Y0TXY # Minimum position of time grid (top)
19752  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
19753  XminXY = X0LXY # Minimum position of time grid (left)
19754  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
19755  UpdateXYAll()
19756 #
19757 # ================ Make XY Plot sub window ==========================
19759  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, EnableUserEntries
19760  global YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
19761  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
19762  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
19763  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
19764  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
19765  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
19766  global FrameRefief, BorderSize, LocalLanguage, User3Entry, User4Entry
19767  global math_tip, bsxy_tip, brxy_tip, snapbutton_tip, savebutton_tip, dismissxybutton_tip, CHAxylab_tip
19768  global CHBxylab_tip, CHAxyofflab_tip, CHBxyofflab_tip, CHAIxyofflab_tip, CHBIxyofflab_tip
19769 
19770  if XYScreenStatus.get() == 0:
19771  XYScreenStatus.set(1)
19772  XYDisp.set(1)
19773  XYCheckBox()
19774  YminXY = Y0TXY # Minimum position of XY grid (top)
19775  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
19776  XminXY = X0LXY # Minimum position of XY grid (left)
19777  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
19778  CANVASwidthXY = GRWXY + (2*X0LXY) # The XY canvas width
19779  CANVASheightXY = GRHXY + 80 # The XY canvas height
19780  xywindow = Toplevel()
19781  xywindow.title("X-Y Plot " + SWRev + RevDate)
19782  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
19783  frame2xyr = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19784  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
19785 
19786  frame2xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19787  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
19788 
19789  frame3xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19790  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
19791 
19792  frame4xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19793  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
19794 
19795  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
19796  XYca.bind('<Configure>', XYcaresize)
19797  XYca.bind('<1>', onCanvasXYLeftClick)
19798  XYca.bind('<3>', onCanvasXYRightClick)
19799  XYca.bind("<Motion>",onCanvasMouse_xy)
19800  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
19801  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
19802  XYca.bind("<Button-5>", onCanvasXYScrollClick)
19803  XYca.bind("<Up>", onCanvasUpArrow)
19804  XYca.bind("<Down>", onCanvasDownArrow)
19805  XYca.bind("<Left>", onCanvasLeftArrow)
19806  XYca.bind("<Right>", onCanvasRightArrow)
19807  XYca.bind("<space>", onCanvasSpaceBar)
19808  XYca.bind("a", onCanvasAverage)
19809  XYca.pack(side=TOP, fill=BOTH, expand=YES)
19810  #
19811  RUNframe = Frame( frame2xyr )
19812  RUNframe.pack(side=TOP)
19813  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
19814  rbxy.pack(side=LEFT)
19815  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
19816  sbxy.pack(side=LEFT)
19817  # Open Math trace menu
19818  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
19819  mathbt.pack(side=TOP) #, anchor=W)
19820  # Disply mode menu
19821  # X - Y mode signal select
19822  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
19823  AxisLabX.pack(side=TOP)
19824  chaxmenu = Frame( frame2xyr )
19825  chaxmenu.pack(side=TOP)
19826  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
19827  rbx2.pack(side=LEFT, anchor=W)
19828  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
19829  rbx3.pack(side=LEFT, anchor=W)
19830  chbxmenu = Frame( frame2xyr )
19831  chbxmenu.pack(side=TOP)
19832  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
19833  rbx4.pack(side=LEFT, anchor=W)
19834  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
19835  rbx5.pack(side=LEFT, anchor=W)
19836  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
19837  rbx7.pack(side=TOP)
19838  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
19839  rbx8.pack(side=TOP)
19840  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
19841  rbx6.pack(side=TOP)
19842  #
19843  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
19844  AxisLabY.pack(side=TOP)
19845  chaymenu = Frame( frame2xyr )
19846  chaymenu.pack(side=TOP)
19847  rby2 = Checkbutton(chaymenu, text='CA-V', variable=YsignalVA, command=UpdateXYTrace)
19848  rby2.pack(side=LEFT, anchor=W)
19849  rby3 = Checkbutton(chaymenu, text='CA-I', variable=YsignalIA, command=UpdateXYTrace)
19850  rby3.pack(side=LEFT, anchor=W)
19851  chbymenu = Frame( frame2xyr )
19852  chbymenu.pack(side=TOP)
19853  rby4 = Checkbutton(chbymenu, text='CB-V', variable=YsignalVB, command=UpdateXYTrace)
19854  rby4.pack(side=LEFT, anchor=W)
19855  rby5 = Checkbutton(chbymenu, text='CB-I', variable=YsignalIB, command=UpdateXYTrace)
19856  rby5.pack(side=LEFT, anchor=W)
19857  rby7 = Checkbutton(frame2xyr, text='Math', variable=YsignalM, command=UpdateXYTrace)
19858  rby7.pack(side=TOP)
19859  mymenu = Frame( frame2xyr )
19860  mymenu.pack(side=TOP)
19861  rby7 = Checkbutton(mymenu, text='Math-X', variable=YsignalMX, command=UpdateXYTrace)
19862  rby7.pack(side=LEFT, anchor=W)
19863  rby8 = Checkbutton(mymenu, text='Math-Y', variable=YsignalMY, command=UpdateXYTrace)
19864  rby8.pack(side=LEFT, anchor=W)
19865  # show cursor menu buttons
19866  cursormenu = Frame( frame2xyr )
19867  cursormenu.pack(side=TOP)
19868  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
19869  cb1.pack(side=LEFT, anchor=W)
19870  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
19871  cb2.pack(side=LEFT, anchor=W)
19872  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
19873  cb4.pack(side=TOP)
19874  #
19875  # Reference trace menu
19876  XYrefmenu = Menubutton(frame2xyr, text="Ref Traces", style="W11.TButton")
19877  XYrefmenu.menu = Menu(XYrefmenu, tearoff = 0 )
19878  XYrefmenu["menu"] = XYrefmenu.menu
19879  XYrefmenu.menu.add_command(label="Save SnapShot", command=BSnapShotXY)
19880  XYrefmenu.menu.add_checkbutton(label="CA-V", variable=XYRefAV, command=UpdateXYTrace)
19881  XYrefmenu.menu.add_checkbutton(label="CA-I", variable=XYRefAI, command=UpdateXYTrace)
19882  XYrefmenu.menu.add_checkbutton(label="CB-V", variable=XYRefBV, command=UpdateXYTrace)
19883  XYrefmenu.menu.add_checkbutton(label="CB-I", variable=XYRefBI, command=UpdateXYTrace)
19884  XYrefmenu.menu.add_checkbutton(label="Math", variable=XYRefM, command=UpdateXYTrace)
19885  XYrefmenu.menu.add_checkbutton(label="Math-X", variable=XYRefMX, command=UpdateXYTrace)
19886  XYrefmenu.menu.add_checkbutton(label="Math-Y", variable=XYRefMY, command=UpdateXYTrace)
19887  XYrefmenu.pack(side=TOP) # , anchor=W)
19888 
19890  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
19891  dismissxybutton.pack(side=TOP)
19892  # Add a pair of user entry wigets
19893  if EnableUserEntries > 0:
19894  UserEnt = Frame( frame2xyr )
19895  UserEnt.pack(side=TOP)
19896  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
19897  userentlab.pack(side=LEFT,fill=X)
19898  User3Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19899  User3Entry.bind('<Return>', onTextKey)
19900  User3Entry.bind('<MouseWheel>', onTextScroll)
19901  User3Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19902  User3Entry.bind("<Button-5>", onTextScroll)
19903  User3Entry.bind('<Key>', onTextKey)
19904  User3Entry.pack(side=LEFT)
19905  User3Entry.delete(0,"end")
19906  User3Entry.insert(0,0.0)
19907  User4Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19908  User4Entry.bind('<Return>', onTextKey)
19909  User4Entry.bind('<MouseWheel>', onTextScroll)
19910  User4Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19911  User4Entry.bind("<Button-5>", onTextScroll)
19912  User4Entry.bind('<Key>', onTextKey)
19913  User4Entry.pack(side=LEFT)
19914  User4Entry.delete(0,"end")
19915  User4Entry.insert(0,0.0)
19916  #
19917  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19918  ADI1xy.pack(side=TOP)
19919  # Bottom Buttons
19920  MarkerXYScale = IntVar(0)
19921  MarkerXYScale.set(1)
19922  # Voltage channel A
19923  CHAsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHvpdiv)
19924  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19925  CHAsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19926  CHAsbxy.bind("<Button-5>", onSpinBoxScroll)
19927  CHAsbxy.pack(side=LEFT)
19928  CHAsbxy.delete(0,"end")
19929  CHAsbxy.insert(0,0.5)
19930  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
19931  CHAxylab.pack(side=LEFT)
19932 
19933  CHAVPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19934  CHAVPosEntryxy.bind('<Return>', onTextKey)
19935  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19936  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19937  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
19938  CHAVPosEntryxy.bind('<Key>', onTextKey)
19939  CHAVPosEntryxy.pack(side=LEFT)
19940  CHAVPosEntryxy.delete(0,"end")
19941  CHAVPosEntryxy.insert(0,2.5)
19942  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
19943  CHAofflabxy.pack(side=LEFT)
19944  # Current channel A
19945  CHAIsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHipdiv)
19946  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19947  CHAIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19948  CHAIsbxy.bind("<Button-5>", onSpinBoxScroll)
19949  CHAIsbxy.pack(side=LEFT)
19950  CHAIsbxy.delete(0,"end")
19951  CHAIsbxy.insert(0,50.0)
19952  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
19953  CHAIlabxy.pack(side=LEFT)
19954 
19955  CHAIPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19956  CHAIPosEntryxy.bind('<Return>', onTextKey)
19957  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
19958  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19959  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
19960  CHAIPosEntryxy.bind('<Key>', onTextKey)
19961  CHAIPosEntryxy.pack(side=LEFT)
19962  CHAIPosEntryxy.delete(0,"end")
19963  CHAIPosEntryxy.insert(0,0.0)
19964  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
19965  CHAIofflabxy.pack(side=LEFT)
19966  # Voltage channel B
19967  CHBsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHvpdiv)
19968  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19969  CHBsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19970  CHBsbxy.bind("<Button-5>", onSpinBoxScroll)
19971  CHBsbxy.pack(side=LEFT)
19972  CHBsbxy.delete(0,"end")
19973  CHBsbxy.insert(0,0.5)
19974  #
19975  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
19976  CHBxylab.pack(side=LEFT)
19977 
19978  CHBVPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
19979  CHBVPosEntryxy.bind('<Return>', onTextKey)
19980  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19981  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19982  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
19983  CHBVPosEntryxy.bind('<Key>', onTextKey)
19984  CHBVPosEntryxy.pack(side=LEFT)
19985  CHBVPosEntryxy.delete(0,"end")
19986  CHBVPosEntryxy.insert(0,2.5)
19987  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
19988  CHBofflabxy.pack(side=LEFT)
19989  # Current channel B
19990  CHBIsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHipdiv) #
19991  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19992  CHBIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19993  CHBIsbxy.bind("<Button-5>", onSpinBoxScroll)
19994  CHBIsbxy.pack(side=LEFT)
19995  CHBIsbxy.delete(0,"end")
19996  CHBIsbxy.insert(0,50.0)
19997  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
19998  CHBIlabxy.pack(side=LEFT)
19999 
20000  CHBIPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
20001  CHBIPosEntryxy.bind('<Return>', onTextKey)
20002  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
20003  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
20004  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
20005  CHBIPosEntryxy.bind('<Key>', onTextKey)
20006  CHBIPosEntryxy.pack(side=LEFT)
20007  CHBIPosEntryxy.delete(0,"end")
20008  CHBIPosEntryxy.insert(0,0.0)
20009  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
20010  CHBIofflabxy.pack(side=LEFT)
20011  #
20012  if ShowBallonHelp > 0:
20013  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
20014  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
20015  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
20016  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
20017  math_tip = CreateToolTip(mathbt, 'Open Math window')
20018  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
20019  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
20020  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
20021  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
20022  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
20023  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
20024  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
20025  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
20026  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
20027  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
20028  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
20029  if LocalLanguage != "English":
20030  BLoadConfig(LocalLanguage)
20031 
20033  global xywindow, XYScreenStatus, ca, XYDisp
20034 
20035  XYScreenStatus.set(0)
20036  XYDisp.set(0)
20037  XYCheckBox()
20038  xywindow.destroy()
20039  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
20040 #
20041 # Optional Calibration procedure routine
20042 #
20044  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
20045  global discontloop, contloop, session, AWGSync, SWRev
20046  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
20047  # setup cal results window
20048  if FWRevOne < 2.06: # Check firmware revision level > 2.06
20049  showwarning("WARNING","Out of date Firmware Revision!")
20050  return
20051  calwindow = Toplevel()
20052  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
20053  # display wigets
20054  SCallab = Label(calwindow, text="Channel Gain / Offset calibration")
20055  SCallab.grid(row=0, column=0, columnspan=2, sticky=W)
20056  labelA0 = Label(calwindow, style="A12B.TLabel")
20057  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
20058  labelA0.config(text = "CA gnd Volts")
20059  labelAMax = Label(calwindow, style="A12B.TLabel")
20060  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
20061  labelAMax.config(text = "CA 584 Volts")
20062  labelAMin = Label(calwindow, style="A12B.TLabel")
20063  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
20064  labelAMin.config(text = "CA 5V Src I ")
20065  labelB0 = Label(calwindow, style="A12B.TLabel")
20066  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
20067  labelB0.config(text = "CA gnd Volts")
20068  labelBMax = Label(calwindow, style="A12B.TLabel")
20069  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
20070  labelBMax.config(text = "CB 584 Volts")
20071  labelBMin = Label(calwindow, style="A12B.TLabel")
20072  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
20073  labelBMin.config(text = "CB 5V Src I ")
20074  labelAB = Label(calwindow, style="A12B.TLabel")
20075  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
20076  labelAB.config(text = "CA 0V Src I")
20077  labelBA = Label(calwindow, style="A12B.TLabel")
20078  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
20079  labelBA.config(text = "CA 0V Src I")
20080  labelSIA0 = Label(calwindow, style="A12B.TLabel")
20081  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
20082  labelSIA0.config(text = "CA 2.5 Src 0 I")
20083  labelSIA = Label(calwindow, style="A12B.TLabel")
20084  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
20085  labelSIA.config(text = "CA 50 Src 100 ")
20086  labelSIAN = Label(calwindow, style="A12B.TLabel")
20087  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
20088  labelSIAN.config(text = "CA 50 Src -45")
20089  labelSIB0 = Label(calwindow, style="A12B.TLabel")
20090  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
20091  labelSIB0.config(text = "CB 2.5 Src 0 I")
20092  labelSIB = Label(calwindow, style="A12B.TLabel")
20093  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
20094  labelSIB.config(text = "CB 50 Src 100 ")
20095  labelSIBN = Label(calwindow, style="A12B.TLabel")
20096  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
20097  labelSIBN.config(text = "CB 50 Src -45")
20098  # set to default mux and dac settings
20099  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
20100  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
20101  AWGSync.set(1)
20102  BAWGSync()
20103  if session.continuous:
20104  print( "ending session")
20105  session.end()
20106  # Setup ADALM1000
20107  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
20108  #print(devx.calibration)
20109  try:
20110  devx.write_calibration("calib_default.txt")
20111  #print "wrote calib_default.txt"
20112  except:
20113  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
20114  devx.write_calibration(filename)
20115  #print(devx.calibration)
20116  #
20117  devidstr = DevID[17:31]
20118  filename = "calib" + devidstr + ".txt"
20119  if os.path.isfile(filename):
20120  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
20121  devx.write_calibration(filename)
20122  #print "wrote old ", filename
20123  calwindow.destroy()
20124  return
20125  else:
20126  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
20127  donothing()
20128  else:
20129  calwindow.destroy()
20130  return
20131  #
20132  CalFile = open(filename, "w")
20133  #
20134  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20135  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20136  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
20137  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
20138  ADsignal1 = [] # Ain signal array channel
20139  ADsignal1 = devx.get_samples(1010)
20140  # Pause whie user connects external voltage reference AD584
20141  BadData = 1
20142  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20143  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20144  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20145  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20146  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
20147  try:
20148  AD584act = float(RequestVRef)*1.0
20149  except:
20150  AD584act = 3.3
20151  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
20152  while (BadData): # loop till good reading
20153  # Get A and B AD584 data
20154  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20155  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20156  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20157  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
20158  # get_samples returns a list of values for voltage [0] and current [1]
20159  for index in range(1000): # calculate average
20160  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20161  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20162 
20163  CHA584Raw = CHA584Raw / 1000.0 # calculate average
20164  CHB584Raw = CHB584Raw / 1000.0 # calculate average
20165  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
20166  labelAMax.config(text = VString) # change displayed value
20167  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
20168  labelBMax.config(text = VString) # change displayed value
20169  Lower = AD584act - 0.3
20170  Upper = AD584act + 0.3
20171  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
20172  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
20173  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20174  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20175  contloop = 0
20176  discontloop = 1
20177  calwindow.destroy()
20178  return
20179  else:
20180  BadData = 0
20181  #
20182  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
20183  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
20184  # Get A GND and B GND data
20185  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20186  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
20187  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20188  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20189  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20190  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20191  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20192  # get_samples returns a list of values for voltage [0] and current [1]
20193  for index in range(1000): # calculate average
20194  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20195  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20196  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20197  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20198 
20199  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
20200  CHAI0gRaw = CHAI0gRaw / 1000.0
20201  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
20202  CHBI0gRaw = CHBI0gRaw / 1000.0
20203  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
20204  labelA0.config(text = VString) # change displayed value
20205  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
20206  labelB0.config(text = VString) # change displayed value
20207  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
20208  # Get A and B data for internal 2.5 rail
20209  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20210  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20211  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
20212  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20213  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20214  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20215  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20216  # get_samples returns a list of values for voltage [0] and current [1]
20217  for index in range(1000): # calculate average
20218  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20219  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20220  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20221  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20222 
20223  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
20224  CHAI02p5Raw = CHAI02p5Raw / 1000.0
20225  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
20226  CHBI02p5Raw = CHBI02p5Raw / 1000.0
20227  # Get A force 0V and B force 0V data
20228  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20229  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20230  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20231  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20232  CHA.mode = Mode.SVMI
20233  CHA.constant(0.0)
20234  CHB.mode = Mode.SVMI
20235  CHB.constant(0.0)
20236  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20237  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
20238  # get_samples returns a list of values for voltage [0] and current [1]
20239  for index in range(1000): # calculate average
20240  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20241  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20242  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20243  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20244 
20245  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
20246  CHAI0F0Raw = CHAI0F0Raw / 1000.0
20247  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
20248  CHBI0F0Raw = CHBI0F0Raw / 1000.0
20249  # Get A force 2.5V and B force 2.5V data
20250  CHA.mode = Mode.SVMI
20251  CHA.constant(4.5)
20252  CHB.mode = Mode.SVMI
20253  CHB.constant(4.5)
20254  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20255  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
20256  # get_samples returns a list of values for voltage [0] and current [1]
20257  for index in range(1000): # calculate average
20258  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20259  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20260  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20261  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20262 
20263  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
20264  CHAI0F25Raw = CHAI0F25Raw / 1000.0
20265  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
20266  CHBI0F25Raw = CHBI0F25Raw / 1000.0
20267  #
20268  # Get A and B measure current data for int 50 res to gnd at 5V
20269  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
20270  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
20271  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20272  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20273  CHA.mode = Mode.SVMI
20274  CHA.constant(5.0)
20275  CHB.mode = Mode.SVMI
20276  CHB.constant(5.0)
20277  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20278  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
20279  for index in range(1000): # calculate average
20280  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20281  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20282  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20283  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20284 
20285  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
20286  CHAISr5vRaw = CHAISr5vRaw / 1000.0
20287  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
20288  CHBISr5vRaw = CHBISr5vRaw / 1000.0
20289  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
20290  labelAMin.config(text = VString) # change displayed value
20291  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
20292  labelBMin.config(text = VString) # change displayed value
20293  # Get A and B measure current data for int 50 res to 2.5 V at 0V
20294  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20295  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20296  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20297  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20298  CHA.mode = Mode.SVMI
20299  CHA.constant(0.001)
20300  CHB.mode = Mode.SVMI
20301  CHB.constant(0.001)
20302  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20303  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
20304  for index in range(1000): # calculate average
20305  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20306  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20307  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20308  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20309 
20310  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
20311  CHAISr0vRaw = CHAISr0vRaw / 1000.0
20312  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
20313  CHBISr0vRaw = CHBISr0vRaw / 1000.0
20314  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
20315  labelAB.config(text = VString) # change displayed value
20316  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
20317  labelBA.config(text = VString) # change displayed value
20318 
20319  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
20320  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20321  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20322  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20323  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20324  CHA.mode = Mode.SIMV
20325  CHA.constant(0.0)
20326  CHB.mode = Mode.SIMV
20327  CHB.constant(0.0)
20328  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20329  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
20330  for index in range(1000): # calculate average
20331  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20332  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20333  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20334  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20335 
20336  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
20337  CHAISr0iRaw = CHAISr0iRaw / 1000.0
20338  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
20339  CHBISr0iRaw = CHBISr0iRaw / 1000.0
20340  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
20341  labelSIA0.config(text = VString) # change displayed value
20342  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
20343  labelSIB0.config(text = VString) # change displayed value
20344  #
20345  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
20346  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20347  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20348  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20349  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20350  CHA.mode = Mode.SIMV
20351  CHA.constant(0.045)
20352  CHB.mode = Mode.SIMV
20353  CHB.constant(0.045)
20354  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20355  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
20356  for index in range(1000): # calculate average
20357  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20358  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20359  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20360  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20361 
20362  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
20363  CHAISr100Raw = CHAISr100Raw / 1000.0
20364  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
20365  CHBISr100Raw = CHBISr100Raw / 1000.0
20366  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
20367  labelSIA.config(text = VString) # change displayed value
20368  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
20369  labelSIB.config(text = VString) # change displayed value
20370  #
20371  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
20372  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20373  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20374  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20375  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20376  CHA.mode = Mode.SIMV
20377  CHA.constant(-0.045)
20378  CHB.mode = Mode.SIMV
20379  CHB.constant(-0.045)
20380  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20381  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
20382  for index in range(1000): # calculate average
20383  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20384  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20385  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20386  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20387 
20388  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
20389  CHAISrN45Raw = CHAISrN45Raw / 1000.0
20390  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
20391  CHBISrN45Raw = CHBISrN45Raw / 1000.0
20392  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
20393  labelSIAN.config(text = VString) # change displayed value
20394  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
20395  labelSIBN.config(text = VString) # change displayed value
20396  # return all switches to open
20397  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20398  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20399  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20400  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20401  # Caculate voltage gain errors
20402  #
20403  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
20404  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
20405  #
20406  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
20407  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
20408  #
20409  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
20410  # print "calculated fixed 2.5 from CHA ", CHA2p5
20411  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
20412  # print "calculated fixed 2.5 from CHB ", CHB2p5
20413  #
20414  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
20415  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
20416  #
20417  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
20418  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
20419  #
20420  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
20421  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
20422  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
20423  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20424  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
20425  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20426  #
20427  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
20428  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
20429  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
20430  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20431  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
20432  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20433  # Write cal factors to file
20434  #
20435  CalFile.write('# Channel A, measure V\n')
20436  CalFile.write('</>\n')
20437  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
20438  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
20439  CalFile.write('<>\n')
20440  CalFile.write('\n')
20441  #
20442  CalFile.write('# Channel A, measure I\n')
20443  CalFile.write('</>\n')
20444  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
20445  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
20446  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
20447  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
20448  CalFile.write('<>\n')
20449  CalFile.write('\n')
20450  #
20451  CalFile.write('# Channel A, source V\n')
20452  CalFile.write('</>\n')
20453  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
20454  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20455  CalFile.write('<>\n')
20456  CalFile.write('\n')
20457  #
20458  CalFile.write('# Channel A, source I\n')
20459  CalFile.write('</>\n')
20460  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
20461  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
20462  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
20463  CalFile.write('<>\n')
20464  CalFile.write('\n')
20465  #
20466  CalFile.write('# Channel B, measure V\n')
20467  CalFile.write('</>\n')
20468  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
20469  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
20470  CalFile.write('<>\n')
20471  CalFile.write('\n')
20472  #
20473  CalFile.write('# Channel B, measure I\n')
20474  CalFile.write('</>\n')
20475  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
20476  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
20477  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
20478  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
20479  CalFile.write('<>\n')
20480  CalFile.write('\n')
20481  #
20482  CalFile.write('# Channel B, source V\n')
20483  CalFile.write('</>\n')
20484  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
20485  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20486  CalFile.write('<>\n')
20487  CalFile.write('\n')
20488  #
20489  CalFile.write('# Channel B source I\n')
20490  CalFile.write('</>\n')
20491  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
20492  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
20493  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
20494  CalFile.write('<>\n')
20495  #
20496  CalFile.close()
20497  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
20498  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
20499  devx.write_calibration(filename)
20500  #print "wrote new " , filename
20501  #
20502  # session.end()
20503  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
20504  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
20505  contloop = 0
20506  discontloop = 1
20507  # session.cancel()
20508  calwindow.destroy()
20509 #
20511  global cal, DevID, devx
20512 
20513  devidstr = DevID[17:31]
20514  filename = "calib" + devidstr + "test.txt"
20515  if os.path.isfile(filename):
20516  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
20517  return
20518  else:
20519  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
20520  donothing()
20521  else:
20522  calwindow.destroy()
20523  return
20524  #
20525  CalFile = open(filename, "w")
20526  #
20527  # Write cal factors to file
20528  # [0]
20529  CalFile.write('# Channel A, measure V\n')
20530  CalFile.write('</>\n')
20531  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
20532  CHAgp = (5.0/cal[0][1])+cal[0][0]
20533  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20534  CalFile.write('<>\n')
20535  CalFile.write('\n')
20536  # [1]
20537  CalFile.write('# Channel A, measure I\n')
20538  CalFile.write('</>\n')
20539  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
20540  CHAgp = (0.1/cal[0][1])+cal[1][0]
20541  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20542  CHAgn = (-0.1/cal[0][2])+cal[1][0]
20543  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
20544  CalFile.write('<>\n')
20545  CalFile.write('\n')
20546  # [2]
20547  CalFile.write('# Channel A, source V\n')
20548  CalFile.write('</>\n')
20549  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
20550  CHAgp = (5.0/cal[2][1])+cal[2][0]
20551  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20552  CalFile.write('<>\n')
20553  CalFile.write('\n')
20554  # [3]
20555  CalFile.write('# Channel A, source I\n')
20556  CalFile.write('</>\n')
20557  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
20558  CHAgp = (0.1/cal[3][1])+cal[3][0]
20559  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20560  CHAgn = (-0.1/cal[3][2])+cal[3][0]
20561  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20562  CalFile.write('<>\n')
20563  CalFile.write('\n')
20564  # [4]
20565  CalFile.write('# Channel B, measure V\n')
20566  CalFile.write('</>\n')
20567  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
20568  CHAgp = (5.0/cal[4][1])+cal[4][0]
20569  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20570  CalFile.write('<>\n')
20571  CalFile.write('\n')
20572  # [5]
20573  CalFile.write('# Channel B, measure I\n')
20574  CalFile.write('</>\n')
20575  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
20576  CHAgp = (0.1/cal[5][1])+cal[5][0]
20577  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20578  CHAgn = (-0.1/cal[5][2])+cal[5][0]
20579  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20580  CalFile.write('<>\n')
20581  CalFile.write('\n')
20582  # [6]
20583  CalFile.write('# Channel B, source V\n')
20584  CalFile.write('</>\n')
20585  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
20586  CHAgp = (5.0/cal[6][1])+cal[6][0]
20587  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20588  CalFile.write('<>\n')
20589  CalFile.write('\n')
20590  # [7]
20591  CalFile.write('# Channel B source I\n')
20592  CalFile.write('</>\n')
20593  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
20594  CHAgp = (0.1/cal[7][1])+cal[7][0]
20595  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20596  CHAgn = (-0.1/cal[7][2])+cal[7][0]
20597  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20598  CalFile.write('<>\n')
20599  #
20600  CalFile.close()
20601 
20603 def SPIShiftOut(DValue):
20604  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
20605 
20606  binstr = bin(DValue)
20607  binlen = len(binstr)
20608  datastr = binstr[2:binlen]
20609  datalen = len(datastr)
20610  if datalen < 16:
20611  datastr = str.rjust(datastr , 16 , '0')
20612  datalen = len(datastr)
20613  i = 1
20614  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
20615  while i < datalen+1:
20616  # sending 0x50 = set to 0, 0x51 = set to 1
20617  D1code = 0x50 + int(datastr[i-1])
20618  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
20619  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20620  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
20621  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20622  i = i + 1
20623  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
20624 #
20625 def SetAD9833(temp):
20626  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
20627  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
20628 
20629  #
20630  if MinigenScreenStatus.get() == 0:
20631  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
20632  #etssrlab.config(text=SRstring)
20633  return
20634  #
20635  if EnableMinigenMode == 2:
20636  MinigenMode.set(40)
20637  #
20638  try:
20639  FminE = float(eval(FminEntry.get()))*1000
20640  except:
20641  if EnableHSsampling > 0:
20642  FminEntry.delete(0,END)
20643  FminEntry.insert(0, FminE/1000)
20644  if MulX == 1:
20645  Fmin = FminE
20646  else:
20647  Fmin = FminE - (FminE/MulX)
20648  #
20649  MinigenFout.delete(0,"end")
20650  MinigenFout.insert(0,Fmin)
20651  #
20652  BSendMG()
20653 
20655 def BSendMG():
20656  global MinigenFclk, MinigenFout, MinigenMode
20657  global Two28, SCLKPort, SDATAPort, SLATCHPort
20658 
20659  DValue = 8192 + MinigenMode.get()
20660  SPIShiftOut(DValue)
20661  try:
20662  fout = float(eval(MinigenFout.get()))
20663  except:
20664  MinigenFout.delete(0,"end")
20665  MinigenFout.insert(0,100)
20666  try:
20667  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
20668  except:
20669  MingenFclk.delete(0,"end")
20670  MinigenFclk.insert(0,16)
20671  Freg = int((fout*Two28)/mclk)
20672  Foutstr = bin(Freg)
20673  Foutlen = len(Foutstr)
20674  datastr = Foutstr[2:Foutlen]
20675  datalen = len(datastr)
20676  if datalen < 28:
20677  datastr = str.rjust(datastr , 28 , '0')
20678  datalen = len(datastr)
20679  Fmsb = '0b01' + datastr[0:14]
20680  Flsb = '0b01' + datastr[14:]
20681  FValue = int(eval(Flsb))
20682  SPIShiftOut(FValue)
20683  FValue = int(eval(Fmsb))
20684  SPIShiftOut(FValue)
20685 
20688  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
20689  global SCLKPort, SDATAPort, SLATCHPort
20690  global GenericSerialStatus
20691  global PIO_0, PIO_1, PIO_2, PIO_3
20692 
20693  if GenericSerialStatus.get() == 1:
20694  GenericSerialStatus.set(0)
20696  if MinigenScreenStatus.get() == 0:
20697  MinigenScreenStatus.set(1)
20698  minigenwindow = Toplevel()
20699  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
20700  minigenwindow.resizable(FALSE,FALSE)
20701  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
20702  #
20703  MinigenMode = IntVar(0)
20704  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
20705  mgb1.grid(row=1, column=0, sticky=W)
20706  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
20707  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
20708  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
20709  mgb3.grid(row=2, column=0, sticky=W)
20710  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
20711  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
20712  f0lab = Label(minigenwindow, text="Mclk in MHz")
20713  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
20714  MinigenFclk = Entry(minigenwindow, width=5)
20715  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
20716  MinigenFclk.delete(0,"end")
20717  MinigenFclk.insert(0,16)
20718  f1lab = Label(minigenwindow, text="Output Freq")
20719  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
20720  MinigenFout = Entry(minigenwindow, width=8, cursor='double_arrow')
20721  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
20722  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
20723  MinigenFout.bind("<Button-5>", onMiniGenScroll)
20724  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
20725  MinigenFout.delete(0,"end")
20726  MinigenFout.insert(0,100)
20727  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
20728  bsn1.grid(row=5, column=0, sticky=W, pady=4)
20729  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
20730  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
20731  #
20732  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
20733  label3.grid(row=6, column=0, sticky=W)
20734  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
20735  sclk1.grid(row=6, column=1, sticky=W)
20736  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
20737  sclk2.grid(row=6, column=2, sticky=W)
20738  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
20739  sclk3.grid(row=6, column=3, sticky=W)
20740  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
20741  sclk4.grid(row=6, column=4, sticky=W)
20742  #
20743  label4 = Label(minigenwindow,text="SData PI/O Port ")
20744  label4.grid(row=7, column=0, sticky=W)
20745  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
20746  sdat1.grid(row=7, column=1, sticky=W)
20747  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
20748  sdat2.grid(row=7, column=2, sticky=W)
20749  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
20750  sdat3.grid(row=7, column=3, sticky=W)
20751  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
20752  sdat4.grid(row=7, column=4, sticky=W)
20753  #
20754  label5 = Label(minigenwindow,text="FSync PI/O Port ")
20755  label5.grid(row=8, column=0, sticky=W)
20756  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
20757  slth1.grid(row=8, column=1, sticky=W)
20758  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
20759  slth2.grid(row=8, column=2, sticky=W)
20760  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
20761  slth3.grid(row=8, column=3, sticky=W)
20762  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
20763  slth4.grid(row=8, column=4, sticky=W)
20764  #
20765 
20768  global minigenwindow, MinigenScreenStatus
20769 
20770  MinigenScreenStatus.set(0)
20771  minigenwindow.destroy()
20772 #
20773 def onMiniGenScroll(event):
20774  global ETSStatus, ETSDisp
20775 
20776  onTextScroll(event)
20777  BSendMG()
20778 
20780 def DA1ShiftOut(D1Value, D2Value):
20781  global devx
20782  global PIO_0, PIO_1, PIO_2, PIO_3
20783 
20784  binstr = bin(D1Value)
20785  binlen = len(binstr)
20786  data1str = binstr[2:binlen]
20787  datalen = len(data1str)
20788  if datalen < 16:
20789  data1str = str.rjust(data1str , 16 , '0')
20790  datalen = len(data1str)
20791  #
20792  binstr = bin(D2Value)
20793  binlen = len(binstr)
20794  data2str = binstr[2:binlen]
20795  datalen = len(data2str)
20796  if datalen < 16:
20797  data2str = str.rjust(data2str , 16 , '0')
20798  datalen = len(data2str)
20799  # sync --> PIO 0
20800  # D0 --> PIO 1
20801  # D1 --> PIO 2
20802  # SCLK --> PIO 3
20803  i = 1
20804 #
20805  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
20806  while i < datalen+1:
20807  # sending 0x50 = set to 0, 0x51 = set to 1
20808  D1code = 0x50 + int(data1str[i-1])
20809  D2code = 0x50 + int(data2str[i-1])
20810  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
20811  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
20812  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20813  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
20814  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20815  i = i + 1
20816  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
20817  #
20818 def BSendDA1():
20819  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
20820 
20821  try:
20822  RefValue = float(eval(REFEntry.get()))
20823  except:
20824  RefValue = 3.3
20825  try:
20826  D1Value = float(eval(DAC1Entry.get()))
20827  except:
20828  D1Value = 0.0129
20829  D1Code = int((D1Value/RefValue)*255)
20830  if D1Code > 255:
20831  D1Code = 255
20832  D1Code = D1Code + 0x2000
20833  try:
20834  D2Value = float(eval(DAC2Entry.get()))
20835  except:
20836  D2Value = 0.0129
20837  D2Code = int((D2Value/RefValue)*255)
20838  if D2Code > 255:
20839  D2Code = 255
20840  D2Code = D2Code + 0x2400
20841  try:
20842  D3Value = float(eval(DAC3Entry.get()))
20843  except:
20844  D3Value = 0.0129
20845  D3Code = int((D3Value/RefValue)*255)
20846  if D3Code > 255:
20847  D3Code = 255
20848  D3Code = D3Code + 0x2000
20849  try:
20850  D4Value = float(eval(DAC4Entry.get()))
20851  except:
20852  D4Value = 0.0129
20853  D4Code = int((D4Value/RefValue)*255)
20854  if D4Code > 255:
20855  D4Code = 255
20856  D4Code = D4Code + 0x2400
20857  #
20858  DA1ShiftOut(D1Code, D3Code)
20859  DA1ShiftOut(D2Code, D4Code)
20860 
20863  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
20864  global REFEntry, RevDate, SWRev
20865 
20866  if DA1ScreenStatus.get() == 0:
20867  DA1ScreenStatus.set(1)
20868  da1window = Toplevel()
20869  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
20870  da1window.resizable(FALSE,FALSE)
20871  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
20872 #
20873  d1lab = Label(da1window, text="DAC A1 output")
20874  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
20875  DAC1Entry = Entry(da1window, width=5)
20876  DAC1Entry.grid(row=0, column=1, sticky=W)
20877  DAC1Entry.delete(0,"end")
20878  DAC1Entry.insert(0,0)
20879  d2lab = Label(da1window, text="DAC B1 output")
20880  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
20881  DAC2Entry = Entry(da1window, width=5)
20882  DAC2Entry.grid(row=1, column=1, sticky=W)
20883  DAC2Entry.delete(0,"end")
20884  DAC2Entry.insert(0,0)
20885 
20886  d3lab = Label(da1window, text="DAC A2 output")
20887  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
20888  DAC3Entry = Entry(da1window, width=5)
20889  DAC3Entry.grid(row=2, column=1, sticky=W)
20890  DAC3Entry.delete(0,"end")
20891  DAC3Entry.insert(0,0)
20892 
20893  d4lab = Label(da1window, text="DAC B2 output")
20894  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
20895  DAC4Entry = Entry(da1window, width=5)
20896  DAC4Entry.grid(row=3, column=1, sticky=W)
20897  DAC4Entry.delete(0,"end")
20898  DAC4Entry.insert(0,0)
20899 
20900  d5lab = Label(da1window, text="Reference V")
20901  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
20902  REFEntry = Entry(da1window, width=5)
20903  REFEntry.grid(row=4, column=1, sticky=W)
20904  REFEntry.delete(0,"end")
20905  REFEntry.insert(0,3.3)
20906 
20907  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
20908  bsn1.grid(row=5, column=0, sticky=W)
20909  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
20910  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
20911 
20914  global da1window, DA1ScreenStatus
20915 
20916  DA1ScreenStatus.set(0)
20917  da1window.destroy()
20918 
20919 def DigPotShiftOut(DValue):
20920  global devx, SingleDualPot
20921  global PIO_0, PIO_1, PIO_2, PIO_3
20922 
20923  binstr = bin(DValue)
20924  binlen = len(binstr)
20925  datastr = binstr[2:binlen]
20926  datalen = len(datastr)
20927  if SingleDualPot.get() == 0: # send 10 bits of data
20928  if datalen < 10:
20929  datastr = str.rjust(datastr , 10 , '0')
20930  datalen = len(datastr)
20931  if SingleDualPot.get() == 1: # send 8 bits of data
20932  if datalen < 8:
20933  datastr = str.rjust(datastr , 8 , '0')
20934  datalen = len(datastr)
20935  if SingleDualPot.get() == 2: # send 8 bits of data
20936  if datalen < 8:
20937  datastr = str.rjust(datastr , 8 , '0')
20938  datalen = len(datastr)
20939  i = 1
20940  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20941  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
20942  while i < datalen+1:
20943  # CS --> PIO 0
20944  # D0 --> PIO 1
20945  # D1 --> PIO 2
20946  # SCLK --> PIO 3
20947  D1code = 0x50 + int(datastr[i-1])
20948  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
20949  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
20950  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20951  i = i + 1
20952  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
20953  #
20954 def DigPotSend(Temp):
20955  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
20956  global SingleDualPot
20957 
20958  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20959  NumTaps = 255
20960  if SingleDualPot.get() == 2:
20961  NumTaps = 63
20962  try:
20963  DValue1 = DigPot1.get()
20964  if DValue1 > NumTaps:
20965  DValue1 = NumTaps
20966  except:
20967  DValue1 = 0
20968  try:
20969  DValue2 = DigPot2.get()
20970  if DValue2 > NumTaps:
20971  DValue2 = NumTaps
20972  except:
20973  DValue2 = 0
20974  try:
20975  DValue3 = DigPot3.get()
20976  if DValue3 > NumTaps:
20977  DValue3 = NumTaps
20978  except:
20979  DValue3 = 0
20980  try:
20981  DValue4 = DigPot4.get()
20982  if DValue4 > NumTaps:
20983  DValue4 = NumTaps
20984  except:
20985  DValue4 = 0
20986  if SendPot1.get() > 0:
20987  DigPotShiftOut(DValue1)
20988  if SendPot2.get() > 0:
20989  DigPotShiftOut(DValue2+NumTaps+1)
20990  if SendPot3.get() > 0:
20991  DigPotShiftOut(DValue3+2*(NumTaps+1))
20992  if SendPot4.get() > 0:
20993  DigPotShiftOut(DValue4+3*(NumTaps+1))
20994 
20996  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
20997 
20998  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20999  DPotlabel.config(text="Enter number from 0 to 255")
21000  DigPot1.config(from_=0, to=255, length=256)
21001  DigPot2.config(from_=0, to=255, length=256)
21002  DigPot3.config(from_=0, to=255, length=256)
21003  DigPot4.config(from_=0, to=255, length=256)
21004  if SingleDualPot.get() == 2:
21005  DPotlabel.config(text="Enter number from 0 to 63")
21006  DigPot1.config(from_=0, to=63, length=64)
21007  DigPot2.config(from_=0, to=63, length=64)
21008  DigPot3.config(from_=0, to=63, length=64)
21009  DigPot4.config(from_=0, to=63, length=64)
21010 
21013  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
21014  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
21015  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
21016 
21017  if DigPotScreenStatus.get() == 0:
21018  DigPotScreenStatus.set(1)
21019  digpotwindow = Toplevel()
21020  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
21021  digpotwindow.resizable(FALSE,FALSE)
21022  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
21023  #
21024  SendPot1 = IntVar(0)
21025  SendPot1.set(1)
21026  SendPot2 = IntVar(0)
21027  SendPot2.set(1)
21028  SendPot3 = IntVar(0)
21029  SendPot3.set(0)
21030  SendPot4 = IntVar(0)
21031  SendPot4.set(0)
21032  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
21033  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
21034 
21035  SingleDualPot = IntVar(0)
21036  SingleDualPot.set(0)
21037  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
21038  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
21039  CompMenu["menu"] = CompMenu.menu
21040  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
21041  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
21042  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
21043  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
21044  lab1 = Checkbutton(digpotwindow,text="Pot 1", variable=SendPot1)
21045  lab1.grid(row=2, column=0, sticky=W)
21046  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21047  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
21048  lab2 = Checkbutton(digpotwindow,text="Pot 2", variable=SendPot2)
21049  lab2.grid(row=4, column=0, sticky=W)
21050  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21051  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
21052  lab3 = Checkbutton(digpotwindow,text="Pot 3", variable=SendPot3)
21053  lab3.grid(row=6, column=0, sticky=W)
21054  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21055  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
21056  lab4 = Checkbutton(digpotwindow,text="Pot 4", variable=SendPot4)
21057  lab4.grid(row=8, column=0, sticky=W)
21058  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
21059  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
21060  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
21061  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
21062 
21064  global digpotwindow, DigPotScreenStatus
21065 
21066  DigPotScreenStatus.set(0)
21067  digpotwindow.destroy()
21068 
21069 def BSendGS():
21070  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21071  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
21072 
21073  if AD5626SerialStatus.get() == 0:
21074  try:
21075  DValue = int(eval(DataBitsEntry.get()))
21076  if DValue < 0:
21077  DValue = 0
21078  except:
21079  DValue = 0
21080  try:
21081  NumBits = int(NumBitsEntry.get())
21082  if NumBits < 1:
21083  NumBits = 1
21084  except:
21085  NumBits = 8
21086  else:
21087  try:
21088  DValue = int(eval(AD5626Entry.get())*1000)
21089  if DValue < 0:
21090  DValue = 0
21091  AD5626Entry.delete(0,"end")
21092  AD5626Entry.insert(0,'0.000')
21093  if DValue > 4095:
21094  DValue = 4095
21095  AD5626Entry.delete(0,"end")
21096  AD5626Entry.insert(0,DValue/1000.0)
21097  except:
21098  DValue = 0
21099  AD5626Entry.delete(0,"end")
21100  AD5626Entry.insert(0,'0.000')
21101  NumBits = 12
21102  # print DValue
21103  binstr = bin(DValue)
21104  binlen = len(binstr)
21105  datastr = binstr[2:binlen]
21106  datalen = len(datastr)
21107  if datalen < NumBits:
21108  datastr = str.rjust(datastr , NumBits , '0')
21109  datalen = len(datastr)
21110  if SLatchPhase.get() == 0:
21111  LatchInt = 0x50
21112  LatchEnd = 0x51
21113  else:
21114  LatchInt = 0x51
21115  LatchEnd = 0x50
21116  if AD5626SerialStatus.get() > 0:
21117  LatchInt = 0x51
21118  LatchEnd = 0x50
21119  if SClockPhase.get() == 0:
21120  ClockInt = 0x50
21121  ClockEnd = 0x51
21122  else:
21123  ClockInt = 0x51
21124  ClockEnd = 0x50
21125  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21126  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21127  i = 1
21128  while i < datalen+1:
21129  if SerDirection.get() == 1: # for MSB first
21130  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
21131  else:
21132  D1code = 0x50 + int(datastr[i-1]) # for LSB first
21133  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21134  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21135  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21136  i = i + 1
21137  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21138  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21139  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21140  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21141 
21144  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21145  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
21146  global PIO_0, PIO_1, PIO_2, PIO_3
21147 
21148  if GenericSerialStatus.get() == 1:
21149  GenericSerialStatus.set(0)
21151  if AD5626SerialStatus.get() == 0:
21152  AD5626SerialStatus.set(1)
21153  ad5626window = Toplevel()
21154  ad5626window.title("AD5626 Output " + SWRev + RevDate)
21155  ad5626window.resizable(FALSE,FALSE)
21156  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
21157 #
21158  SLatchPhase = IntVar(0)
21159  SLatchPhase.set(0)
21160  SClockPhase = IntVar(0)
21161  SClockPhase.set(1)
21162  SerDirection = IntVar(0)
21163  SerDirection.set(0)
21164  #
21165  label2 = Label(ad5626window,text="Enter Output Volts")
21166  label2.grid(row=1, column=0, columnspan=1, sticky=W)
21167  AD5626Entry = Entry(ad5626window, width=10, cursor='double_arrow')
21168  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
21169  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
21170  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
21171  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
21172  AD5626Entry.delete(0,"end")
21173  AD5626Entry.insert(0,'0.000')
21174  #
21175  label3 = Label(ad5626window,text="SCLK PI/O Port ")
21176  label3.grid(row=2, column=0, columnspan=1, sticky=W)
21177  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
21178  sclk1.grid(row=2, column=1, sticky=W)
21179  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
21180  sclk2.grid(row=2, column=2, sticky=W)
21181  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
21182  sclk3.grid(row=2, column=3, sticky=W)
21183  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
21184  sclk4.grid(row=2, column=4, sticky=W)
21185  #
21186  label4 = Label(ad5626window,text="SData PI/O Port ")
21187  label4.grid(row=3, column=0, columnspan=1, sticky=W)
21188  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
21189  sdat1.grid(row=3, column=1, sticky=W)
21190  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
21191  sdat2.grid(row=3, column=2, sticky=W)
21192  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
21193  sdat3.grid(row=3, column=3, sticky=W)
21194  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
21195  sdat4.grid(row=3, column=4, sticky=W)
21196  #
21197  label5 = Label(ad5626window,text="Latch PI/O Port ")
21198  label5.grid(row=4, column=0, columnspan=1, sticky=W)
21199  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
21200  slth1.grid(row=4, column=1, sticky=W)
21201  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
21202  slth2.grid(row=4, column=2, sticky=W)
21203  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
21204  slth3.grid(row=4, column=3, sticky=W)
21205  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
21206  slth4.grid(row=4, column=4, sticky=W)
21207  #
21208  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
21209  bsn1.grid(row=5, column=0, sticky=W)
21210  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
21211  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21212 #
21213 def onAD5626Scroll(event):
21214  onTextScroll(event)
21215  BSendGS()
21216 
21218  global ad5626window, AD5626SerialStatus
21219 
21220  AD5626SerialStatus.set(0)
21221  ad5626window.destroy()
21222 
21224  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21225  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
21226  global PIO_0, PIO_1, PIO_2, PIO_3
21227 
21228  if GenericSerialStatus.get() == 0:
21229  GenericSerialStatus.set(1)
21230  serialwindow = Toplevel()
21231  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
21232  serialwindow.resizable(FALSE,FALSE)
21233  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
21234  #
21235  SCLKPort = IntVar(0)
21236  SCLKPort.set(PIO_2)
21237  SDATAPort = IntVar(0)
21238  SDATAPort.set(PIO_1)
21239  SLATCHPort = IntVar(0)
21240  SLATCHPort.set(PIO_0)
21241  SLatchPhase = IntVar(0)
21242  SClockPhase = IntVar(0)
21243  SerDirection = IntVar(0)
21244  label = Label(serialwindow,text="Enter number of Bits")
21245  label.grid(row=1, column=0, columnspan=2, sticky=W)
21246  NumBitsEntry = Entry(serialwindow, width=3)
21247  NumBitsEntry.grid(row=1, column=2, sticky=W)
21248  NumBitsEntry.delete(0,"end")
21249  NumBitsEntry.insert(0,8)
21250  #
21251  label2 = Label(serialwindow,text="Enter Data Word")
21252  label2.grid(row=2, column=0, columnspan=1, sticky=W)
21253  DataBitsEntry = Entry(serialwindow, width=10)
21254  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
21255  DataBitsEntry.delete(0,"end")
21256  DataBitsEntry.insert(0,0)
21257  #
21258  label3 = Label(serialwindow,text="SCLK PI/O Port ")
21259  label3.grid(row=3, column=0, columnspan=1, sticky=W)
21260  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
21261  sclk1.grid(row=3, column=1, sticky=W)
21262  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
21263  sclk2.grid(row=3, column=2, sticky=W)
21264  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
21265  sclk3.grid(row=3, column=3, sticky=W)
21266  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
21267  sclk4.grid(row=3, column=4, sticky=W)
21268  #
21269  label4 = Label(serialwindow,text="SData PI/O Port ")
21270  label4.grid(row=4, column=0, columnspan=1, sticky=W)
21271  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
21272  sdat1.grid(row=4, column=1, sticky=W)
21273  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
21274  sdat2.grid(row=4, column=2, sticky=W)
21275  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
21276  sdat3.grid(row=4, column=3, sticky=W)
21277  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
21278  sdat4.grid(row=4, column=4, sticky=W)
21279  #
21280  label5 = Label(serialwindow,text="Latch PI/O Port ")
21281  label5.grid(row=5, column=0, columnspan=1, sticky=W)
21282  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
21283  slth1.grid(row=5, column=1, sticky=W)
21284  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
21285  slth2.grid(row=5, column=2, sticky=W)
21286  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
21287  slth3.grid(row=5, column=3, sticky=W)
21288  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
21289  slth4.grid(row=5, column=4, sticky=W)
21290  #
21291  label6 = Label(serialwindow,text="Latch Phase ")
21292  label6.grid(row=6, column=0, columnspan=1, sticky=W)
21293  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
21294  sph1.grid(row=6, column=1, sticky=W)
21295  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
21296  sph2.grid(row=6, column=2, sticky=W)
21297  #
21298  label7 = Label(serialwindow,text="Clock Phase ")
21299  label7.grid(row=7, column=0, columnspan=1, sticky=W)
21300  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
21301  sph7.grid(row=7, column=1, sticky=W)
21302  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
21303  sph8.grid(row=7, column=2, sticky=W)
21304  #
21305  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
21306  sdir1.grid(row=8, column=0, sticky=W)
21307  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
21308  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
21309 
21310  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
21311  bsn1.grid(row=9, column=0, sticky=W)
21312  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
21313  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
21314 
21316  global serialwindow, GenericSerialStatus
21317 
21318  GenericSerialStatus.set(0)
21319  serialwindow.destroy()
21320 
21323  global digfltwindow, DigFiltStatus, RevDate, SWRev, DeBugMode
21324  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
21325  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
21326  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
21327  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, AWGFiltAFile
21328  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength, AWGFiltBFile
21329 
21330  if DigFiltStatus.get() == 0:
21331  DigFiltStatus.set(1)
21332  digfltwindow = Toplevel()
21333  digfltwindow.title("Digital Filter " + SWRev + RevDate)
21334  digfltwindow.resizable(FALSE,FALSE)
21335  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
21336  #
21337  scriptbutton = Button(digfltwindow, text="Run Script", style="W11.TButton", command=RunScript)
21338  scriptbutton.grid(row=0, column=0, columnspan=1, sticky=W)
21339  dismissdfbutton = Button(digfltwindow, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21340  dismissdfbutton.grid(row=0, column=1, columnspan=1, sticky=W)
21341  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
21342  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
21343  #frame2.pack(side=LEFT, expand=1, fill=X)
21344  #frame3.pack(side=LEFT, expand=1, fill=X)
21345  frame2.grid(row=1, column=0, sticky=W)
21346  frame3.grid(row=1, column=1, sticky=W)
21347  frame4 = LabelFrame(digfltwindow, text="AWG A Filter", style="A10R1.TLabelframe")
21348  frame5 = LabelFrame(digfltwindow, text="AWG B Filter", style="A10R2.TLabelframe")
21349  frame4.grid(row=2, column=0, sticky=W)
21350  frame5.grid(row=2, column=1, sticky=W)
21351  #
21352  digfilta = Frame( frame2 )
21353  digfilta.pack(side=LEFT)
21354  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
21355  #titlab.grid(row=0, column=0, sticky=W)
21356  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
21357  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
21358  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
21359  lab3.grid(row=1, column=0, sticky=W)
21360  BCALenEntry = Entry(digfilta, width=3, cursor='double_arrow')
21361  BCALenEntry.bind("<Return>", onRetDigFiltA)
21362  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
21363  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
21364  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
21365  # BCALenEntry.bind('<Key>', onTextKey)
21366  BCALenEntry.grid(row=1, column=1, sticky=W)
21367  BCALenEntry.delete(0,"end")
21368  BCALenEntry.insert(0,2)
21369  bcalab = Label(digfilta, text="Length")
21370  bcalab.grid(row=1, column=2, sticky=W)
21371  DifFiltALength = Label(digfilta, text="Length = 0 ")
21372  DifFiltALength.grid(row=2, column=0, sticky=W)
21373  DifFiltAFile = Label(digfilta, text="File Name, none ")
21374  DifFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21375  cald = Button(digfilta, text='Load From File', command=BLoadDFiltA)
21376  cald.grid(row=4, column=0, columnspan=3, sticky=W)
21377  cacb = Button(digfilta, text='Load From Clip Board', command=BLoadDFiltAClip)
21378  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
21379  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
21380  camath.grid(row=6, column=0, columnspan=3, sticky=W)
21381 
21382  # Deskew controls
21383  lab5 = Checkbutton(digfilta, text="DeSkew A", variable=DigDeSkewA)# , command=BuildBoxCarA)
21384  lab5.grid(row=7, column=0, sticky=W)
21385  BCASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
21386  BCASkewEntry.bind('<MouseWheel>', onTextScroll)
21387  BCASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21388  BCASkewEntry.bind("<Button-5>", onTextScroll)
21389  BCASkewEntry.grid(row=7, column=1, sticky=W)
21390  BCASkewEntry.delete(0,"end")
21391  BCASkewEntry.insert(0,0)
21392  bcasklab = Label(digfilta, text="# Samples")
21393  bcasklab.grid(row=7, column=2, sticky=W)
21394  #
21395  #dismissdfbutton = Button(digfilta, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21396  #dismissdfbutton.grid(row=7, column=0, columnspan=1, sticky=W)
21397  #
21398  digfiltb = Frame( frame3 )
21399  digfiltb.pack(side=RIGHT)
21400  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
21401  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
21402  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
21403  lab4.grid(row=1, column=0, sticky=W)
21404  BCBLenEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21405  BCBLenEntry.bind("<Return>", onRetDigFiltB)
21406  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
21407  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
21408  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
21409  # BCALenEntry.bind('<Key>', onTextKey)
21410  BCBLenEntry.grid(row=1, column=1, sticky=W)
21411  BCBLenEntry.delete(0,"end")
21412  BCBLenEntry.insert(0,2)
21413  bcblab = Label(digfiltb, text="Length")
21414  bcblab.grid(row=1, column=2, sticky=W)
21415  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
21416  DifFiltBLength.grid(row=2, column=0, sticky=W)
21417  DifFiltBFile = Label(digfiltb,text="File Name, none ")
21418  DifFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21419  cbld = Button(digfiltb, text='Load From File', command=BLoadDFiltB)
21420  cbld.grid(row=4, column=0, columnspan=3, sticky=W)
21421  cacb = Button(digfiltb, text='Load From Clip Board', command=BLoadDFiltBClip)
21422  cacb.grid(row=5, column=0, columnspan=3, sticky=W)
21423  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
21424  cbmath.grid(row=6, column=0, columnspan=3, sticky=W)
21425  # Deskew controls
21426  lab6 = Checkbutton(digfiltb,text="DeSkew B", variable=DigDeSkewB)# , command=BuildBoxCarA)
21427  lab6.grid(row=7, column=0, sticky=W)
21428  BCBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21429  BCBSkewEntry.bind('<MouseWheel>', onTextScroll)
21430  BCBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21431  BCBSkewEntry.bind("<Button-5>", onTextScroll)
21432  BCBSkewEntry.grid(row=7, column=1, sticky=W)
21433  BCBSkewEntry.delete(0,"end")
21434  BCBSkewEntry.insert(0,0)
21435  bcbsklab = Label(digfiltb, text="# Samples")
21436  bcbsklab.grid(row=7, column=2, sticky=W)
21437  # AWG A controls
21438  awgfilta = Frame( frame4 )
21439  awgfilta.pack(side=LEFT)
21440  lab7 = Checkbutton(awgfilta,text="Filter AWG A", variable=AWGFiltA, command=ReMakeAWGwaves)
21441  lab7.grid(row=0, column=0, columnspan=2, sticky=W)
21442  lab8 = Checkbutton(awgfilta,text="Box Car", variable=AWGFiltABoxCar, command=BuildAWGBoxCarA)
21443  lab8.grid(row=1, column=0, sticky=W)
21444  AWGALenEntry = Entry(awgfilta, width=3, cursor='double_arrow')
21445  AWGALenEntry.bind("<Return>", onRetAWGFiltA)
21446  AWGALenEntry.bind('<MouseWheel>', onAWGFiltAScroll)
21447  AWGALenEntry.bind("<Button-4>", onAWGFiltAScroll)# with Linux OS
21448  AWGALenEntry.bind("<Button-5>", onAWGFiltAScroll)
21449  # BCALenEntry.bind('<Key>', onTextKey)
21450  AWGALenEntry.grid(row=1, column=1, sticky=W)
21451  AWGALenEntry.delete(0,"end")
21452  AWGALenEntry.insert(0,2)
21453  awgalab = Label(awgfilta, text="Length")
21454  awgalab.grid(row=1, column=2, sticky=W)
21455  AWGFiltALength = Label(awgfilta, text="Length = 0 ")
21456  AWGFiltALength.grid(row=2, column=0, sticky=W)
21457  AWGFiltAFile = Label(awgfilta, text="File Name, none ")
21458  AWGFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21459  awgaload = Button(awgfilta, text='Load From File', command=BLoadAWGFiltA)
21460  awgaload.grid(row=4, column=0, columnspan=3, sticky=W)
21461  awgacb = Button(awgfilta, text='Load From Clip Board', command=BLoadAWGAFiltClip)
21462  awgacb.grid(row=5, column=0, columnspan=3, sticky=W)
21463  awgamath = Button(awgfilta, text='AWG A Filter formula', command=BAWGFiltAMath)
21464  awgamath.grid(row=6, column=0, columnspan=3, sticky=W)
21465  #
21466  # AWG B controls
21467  awgfiltb = Frame( frame5 )
21468  awgfiltb.pack(side=RIGHT)
21469  lab9 = Checkbutton(awgfiltb,text="Filter AWG B", variable=AWGFiltB, command=ReMakeAWGwaves)
21470  lab9.grid(row=0, column=0, columnspan=2, sticky=W)
21471  lab10 = Checkbutton(awgfiltb,text="Box Car", variable=AWGFiltBBoxCar, command=BuildAWGBoxCarB)
21472  lab10.grid(row=1, column=0, sticky=W)
21473  AWGBLenEntry = Entry(awgfiltb, width=3, cursor='double_arrow')
21474  AWGBLenEntry.bind("<Return>", onRetAWGFiltB)
21475  AWGBLenEntry.bind('<MouseWheel>', onAWGFiltBScroll)
21476  AWGBLenEntry.bind("<Button-4>", onAWGFiltBScroll)# with Linux OS
21477  AWGBLenEntry.bind("<Button-5>", onAWGFiltBScroll)
21478  # BCALenEntry.bind('<Key>', onTextKey)
21479  AWGBLenEntry.grid(row=1, column=1, sticky=W)
21480  AWGBLenEntry.delete(0,"end")
21481  AWGBLenEntry.insert(0,2)
21482  awgblab = Label(awgfiltb, text="Length")
21483  awgblab.grid(row=1, column=2, sticky=W)
21484  AWGFiltBLength = Label(awgfiltb, text="Length = 0 ")
21485  AWGFiltBLength.grid(row=2, column=0, sticky=W)
21486  AWGFiltBFile = Label(awgfiltb, text="File Name, none ")
21487  AWGFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21488  awgbload = Button(awgfiltb, text='Load From File', command=BLoadAWGFiltB)
21489  awgbload.grid(row=4, column=0, columnspan=3, sticky=W)
21490  awgbcb = Button(awgfiltb, text='Load From Clip Board', command=BLoadAWGBFiltClip)
21491  awgbcb.grid(row=5, column=0, columnspan=3, sticky=W)
21492  awgbmath = Button(awgfiltb, text='AWG B Filter formula', command=BAWGFiltBMath)
21493  awgbmath.grid(row=6, column=0, columnspan=3, sticky=W)
21494  #
21495 def onRetDigFiltA(event):
21496  BuildBoxCarA()
21497 
21498 def onDigFiltAScroll(event):
21499  onTextScroll(event)
21500  BuildBoxCarA()
21501 
21503  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
21504 
21505  if DigFiltABoxCar.get() == 0:
21506  return
21507 
21508  FLength = int(BCALenEntry.get())
21509  if FLength < 2:
21510  return
21511 
21512  DFiltACoef = [] # empty coef array
21513 
21514  for n in range(FLength):
21515  DFiltACoef.append(float(1.0/FLength))
21516 
21517  DFiltACoef = numpy.array(DFiltACoef)
21518  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21519 
21520 def onRetDigFiltB(event):
21521  BuildBoxCarB()
21522 
21523 def onDigFiltBScroll(event):
21524  onTextScroll(event)
21525  BuildBoxCarB()
21526 
21528  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
21529 
21530  if DigFiltBBoxCar.get() == 0:
21531  return
21532 
21533  FLength = int(BCBLenEntry.get())
21534  if FLength < 2:
21535  return
21536 
21537  DFiltBCoef = [] # empty coef array
21538 
21539  for n in range(FLength):
21540  DFiltBCoef.append(float(1.0/FLength))
21541 
21542  DFiltBCoef = numpy.array(DFiltBCoef)
21543  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21544 
21546  global digfltwindow, DigFiltStatus
21547 
21548  DigFiltStatus.set(0)
21549  digfltwindow.destroy()
21550 
21552  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
21553 
21554 # Read values from CVS file
21555  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21556  try:
21557  CSVFile = open(filename)
21558  csv_f = csv.reader(CSVFile)
21559  except:
21560  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21561  return
21562  DFiltACoef = []
21563 
21564  for row in csv_f:
21565  try:
21566  DFiltACoef.append(float(row[0]))
21567  except:
21568  print( 'skipping non-numeric row')
21569  DFiltACoef = numpy.array(DFiltACoef)
21570  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21571  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21572  CSVFile.close()
21573 #
21575  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
21576 
21577  TempString = DigFilterAString
21578  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
21579  if (DigFilterAString == None): # If Cancel pressed, then None
21580  DigFilterAString = TempString
21581  return
21582  DFiltACoef = eval(DigFilterAString)
21583  DFiltACoef = numpy.array(DFiltACoef)
21584  coefsum = numpy.sum(DFiltACoef)
21585  DFiltACoef = DFiltACoef / coefsum # always normalize to a gain of one
21586  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21587  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
21588 
21590  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
21591 
21592 # Read values from CVS file
21593  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21594  try:
21595  CSVFile = open(filename)
21596  csv_f = csv.reader(CSVFile)
21597  except:
21598  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21599  return
21600  DFiltBCoef = []
21601 
21602  for row in csv_f:
21603  try:
21604  DFiltBCoef.append(float(row[0]))
21605  except:
21606  print( 'skipping non-numeric row')
21607  DFiltBCoef = numpy.array(DFiltBCoef)
21608  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21609  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21610  CSVFile.close()
21611 #
21613  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
21614 
21615  TempString = DigFilterBString
21616  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
21617  if (DigFilterBString == None): # If Cancel pressed, then None
21618  DigFilterBString = TempString
21619  return
21620  DFiltBCoef = eval(DigFilterBString)
21621  DFiltBCoef = numpy.array(DFiltBCoef)
21622  coefsum = numpy.sum(DFiltBCoef)
21623  DFiltBCoef = DFiltBCoef / coefsum
21624  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21625  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
21626 #
21627 def onRetAWGFiltA(event):
21628  BuildAWGBoxCarA()
21629 
21630 def onAWGFiltAScroll(event):
21631  onTextScroll(event)
21632  BuildAWGBoxCarA()
21633 
21635  global AWGALenEntry, AWGFiltACoef, AWGFiltABoxCar, AWGFiltALength
21636 
21637  if AWGFiltABoxCar.get() == 0:
21638  return
21639 
21640  FLength = int(AWGALenEntry.get())
21641  if FLength < 2:
21642  return
21643 
21644  AWGFiltACoef = [] # empty coef array
21645 
21646  for n in range(FLength):
21647  AWGFiltACoef.append(float(1.0/FLength))
21648 
21649  AWGFiltACoef = numpy.array(AWGFiltACoef)
21650  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21651  ReMakeAWGwaves()
21652 #
21653 def onRetAWGFiltB(event):
21654  BuildAWGBoxCarb()
21655 
21656 def onAWGFiltBScroll(event):
21657  onTextScroll(event)
21658  BuildAWGBoxCarB()
21659 
21661  global AWGBLenEntry, AWGFiltBCoef, AWGFiltBBoxCar, AWGFiltBLength
21662 
21663  if AWGFiltBBoxCar.get() == 0:
21664  return
21665 
21666  FLength = int(AWGBLenEntry.get())
21667  if FLength < 2:
21668  return
21669 
21670  AWGFiltBCoef = [] # empty coef array
21671 
21672  for n in range(FLength):
21673  AWGFiltBCoef.append(float(1.0/FLength))
21674 
21675  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21676  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21677  ReMakeAWGwaves()
21678 #
21680  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile
21681 
21682 # Read values from CVS file
21683  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21684  try:
21685  CSVFile = open(filename)
21686  csv_f = csv.reader(CSVFile)
21687  except:
21688  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21689  return
21690  AWGFiltACoef = []
21691 
21692  for row in csv_f:
21693  try:
21694  AWGFiltACoef.append(float(row[0]))
21695  except:
21696  print( 'skipping non-numeric row')
21697  AWGFiltACoef = numpy.array(AWGFiltACoef)
21698  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21699  AWGFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21700  CSVFile.close()
21701  ReMakeAWGwaves()
21702 #
21704  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile, AWGFilterAString
21705 
21706  TempString = AWGFilterAString
21707  AWGFilterAString = askstring("AWG A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=AWGFilterAString, parent=digfltwindow)
21708  if (AWGFilterAString == None): # If Cancel pressed, then None
21709  AWGFilterAString = TempString
21710  return
21711  AWGFiltACoef = eval(AWGFilterAString)
21712  AWGFiltACoef = numpy.array(AWGFiltACoef)
21713  coefsum = numpy.sum(AWGFiltACoef)
21714  AWGFiltACoef = AWGFiltACoef / coefsum
21715  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21716  AWGFiltAFile.config(text = "AWG A Filter formula" ) # change displayed file name
21717  ReMakeAWGwaves()
21718 #
21719 #
21721  global AWGFiltBCoef, digfltwindow, AWGFiltbLength, AWGFiltBFile
21722 
21723 # Read values from CVS file
21724  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21725  try:
21726  CSVFile = open(filename)
21727  csv_f = csv.reader(CSVFile)
21728  except:
21729  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21730  return
21731  AWGFiltBCoef = []
21732 
21733  for row in csv_f:
21734  try:
21735  AWGFiltBCoef.append(float(row[0]))
21736  except:
21737  print( 'skipping non-numeric row')
21738  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21739  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21740  AWGFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21741  CSVFile.close()
21742  ReMakeAWGwaves()
21743 #
21745  global AWGFiltBCoef, digfltwindow, AWGFiltBLength, AWGFiltBFile, AWGFilterBString
21746 
21747  TempString = AWGFilterBString
21748  AWGFilterBString = askstring("AWG B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=AWGFilterBString, parent=digfltwindow)
21749  if (AWGFilterBString == None): # If Cancel pressed, then None
21750  AWGFilterBString = TempString
21751  return
21752  AWGFiltBCoef = eval(AWGFilterBString)
21753  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21754  coefsum = numpy.sum(AWGFiltBCoef)
21755  AWGFiltBCoef = AWGFiltBCoef / coefsum
21756  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21757  AWGFiltBFile.config(text = "AWG B Filter formula" ) # change displayed file name
21758  ReMakeAWGwaves()
21759 #
21760 # Higher order SINC filters can be generated by convolving first order Box Car filters
21761 def BuildRejectFilter(Order, Freject, Fsample):
21762  # Order can be 1, 2, 3 or 4
21763  # Fsample = 100000
21764  # Calculate SINC1 oversample ratios for Freject
21765  osr = int(Fsample/Freject) #
21766  # osr60 = int(Fsample/60) # 60 Hz example
21767  # Create "boxcar" SINC1 filter
21768  sinc1 = numpy.ones(osr)
21769  # sinc1_60 = np.ones(osr60)
21770  # Calculate higher order filters
21771  sinc2 = numpy.convolve(sinc1, sinc1)
21772  sinc3 = numpy.convolve(sinc2, sinc1)
21773  sinc4 = numpy.convolve(sinc2, sinc2)
21774  fosr = float(Fsample/Freject)
21775  if Order == 1:
21776  return sinc1/fosr
21777  elif Order == 2:
21778  return sinc2/fosr
21779  elif Order == 3:
21780  return sinc3/fosr
21781  elif Order == 4:
21782  return sinc4/fosr
21783  else:
21784  return sinc1/fosr
21785  # Here's the SINC4-ish filter
21786  # with three zeros at 50Hz, one at 60Hz.
21787  # filt_50_60_rej = np.convolve(sinc3_50, sinc1_60)
21788 
21789 # Fit the function y = A * exp(B * x) to the data arrays xs and ys
21790 # returns (A, B)
21791 # From: https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
21792 def fit_exp(xs, ys):
21793  S_x2_y = 0.0
21794  S_y_lny = 0.0
21795  S_x_y = 0.0
21796  S_x_y_lny = 0.0
21797  S_y = 0.0
21798  for (x,y) in zip(xs, ys):
21799  S_x2_y += x * x * y
21800  S_y_lny += y * numpy.log(y)
21801  S_x_y += x * y
21802  S_x_y_lny += x * y * numpy.log(y)
21803  S_y += y
21804  #end
21805  a = (S_x2_y * S_y_lny - S_x_y * S_x_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21806  b = (S_y * S_x_y_lny - S_x_y * S_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21807  return (numpy.exp(a), b)
21808 #
21810  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
21811 
21812  if CommandStatus.get() == 0:
21813  CommandStatus.set(1)
21814  commandwindow = Toplevel()
21815  commandwindow.title("Command Line " + SWRev + RevDate)
21816  commandwindow.resizable(FALSE,FALSE)
21817  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
21818  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
21819  toplab.grid(row=0, column=0, columnspan=4, sticky=W)
21820  cl1 = Label(commandwindow,text="Last command:")
21821  cl1.grid(row=1, column=0, sticky=W)
21822  LastCommand = Label(commandwindow,text=" ")
21823  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
21824  ExecString = Entry(commandwindow, width=40)
21825  ExecString.bind("<Return>", RExecuteFromString)
21826  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
21827  ExecString.delete(0,"end")
21828  ExecString.insert(0,"")
21829  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
21830  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
21831  scriptbutton = Button(commandwindow, text="Run Script", style="W10.TButton", command=RunScript)
21832  scriptbutton.grid(row=4, column=1, sticky=W, pady=8)
21833  #
21834  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
21835  dismissclbutton.grid(row=4, column=2, sticky=W, pady=7)
21836 
21838  global commandwindow, CommandStatus
21839 
21840  CommandStatus.set(0)
21841  commandwindow.destroy()
21842 
21844 
21846 
21847 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
21848  global ExecString, LastCommand
21849  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
21850  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
21851  global VUnAvgA, VUnAvgB, IUnAvgA, IUnAvgB, UnAvgSav
21852  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
21853  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
21854  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
21855  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
21856  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
21857  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
21858  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
21859  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
21860  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
21861  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
21862  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
21863  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
21864  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
21865  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
21866  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
21867  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
21868  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
21869  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
21870  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
21871  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
21872  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
21873  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
21874  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
21875  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
21876  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
21877  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
21878  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
21879  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
21880  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
21881  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
21882  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
21883  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
21884  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
21885  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21886  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21887  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21888  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21889  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
21890  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
21891  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
21892  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
21893  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
21894  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
21895  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
21896  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
21897  global phawindow, PhAca, PhAScreenStatus, PhADisp
21898  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
21899  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
21900  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
21901  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
21902  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
21903  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
21904  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
21905  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
21906  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
21907 
21908  try:
21909  exec( ExecString.get(), globals(), globals())
21910  # exec( ExecString.get() )
21911  LastCommand.config(text = ExecString.get() ) # change displayed last command
21912  except:
21913  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
21914  return()
21915 #
21916 def CAresize(event):
21917  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
21918 
21919  XOL = FontSize * 7
21920  CANVASwidth = event.width - 4
21921  CANVASheight = event.height - 4
21922  GRW = CANVASwidth - (2 * X0L) # new grid width
21923  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
21924  UpdateTimeAll()
21925 #
21927  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21928  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21929  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21930  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21931  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21932  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21933 
21934  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
21935  ChaValue1.config(text = ValueText)
21936  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
21937  ChaValue2.config(text = ValueText)
21938  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
21939  ChaValue3.config(text = ValueText)
21940  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
21941  ChaValue4.config(text = ValueText)
21942  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
21943  ChaValue5.config(text = ValueText)
21944  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
21945  ChaValue6.config(text = ValueText)
21946  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
21947  ChbValue1.config(text = ValueText)
21948  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
21949  ChbValue2.config(text = ValueText)
21950  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
21951  ChbValue3.config(text = ValueText)
21952  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
21953  ChbValue4.config(text = ValueText)
21954  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
21955  ChbValue5.config(text = ValueText)
21956  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
21957  ChbValue6.config(text = ValueText)
21958 #
21960  global measurewindow, MeasureStatus, RevDate, SWRev
21961  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21962  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21963  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21964  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21965  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21966  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21967 
21968  if MeasureStatus.get() == 0:
21969  MeasureStatus.set(1)
21970  measurewindow = Toplevel()
21971  measurewindow.title("Measurements " + SWRev + RevDate)
21972  measurewindow.resizable(FALSE,FALSE)
21973  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
21974  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
21975  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
21976  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
21977  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
21978  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21979  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
21980  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
21981  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
21982  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21983  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
21984  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
21985  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
21986  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21987  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
21988  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
21989  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
21990  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21991  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
21992  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
21993  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
21994  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21995  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
21996  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
21997  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
21998  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21999  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
22000  #
22001  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
22002  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
22003  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22004  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
22005  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
22006  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
22007  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22008  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
22009  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
22010  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
22011  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22012  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
22013  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
22014  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
22015  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22016  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
22017  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
22018  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
22019  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22020  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
22021  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
22022  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
22023  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
22024  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
22025 #
22027  global measurewindow, MeasureStatus
22028 
22029  MeasureStatus.set(0)
22030  measurewindow.destroy()
22031 #
22033  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
22034  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22035 
22036  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
22037  if BoardStatus.get() == 0:
22038  BoardStatus.set(1)
22039  boardwindow = Toplevel()
22040  boardwindow.title("Select Board " + RevDate)
22041  boardwindow.resizable(FALSE,FALSE)
22042  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
22043  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
22044  toplab.pack(side=TOP)
22045  for idx, devx in enumerate(session.devices):
22046  BrdText = "Board # " + str(idx)
22047  if idx == 0:
22048  devx.set_led(0b010) # LED.green
22049  FWRevOne = float(devx.fwver)
22050  HWRevOne = devx.hwver
22051  dev0 = devx #session.devices[0]
22052  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22053  elif idx == 1:
22054  devx.set_led(0b100) # LED.blue,
22055  FWRevTwo = float(devx.fwver)
22056  HWRevTwo = devx.hwver
22057  dev1 = devx #session.devices[1]
22058  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
22059  elif idx == 2:
22060  devx.set_led(0b001) # LED.red,
22061  FWRevThree = float(devx.fwver)
22062  HWRevThree = devx.hwver
22063  dev2 = devx #session.devices[2]
22064  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22065  else:
22066  dev3 = session.devices[3]
22067  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
22068  brd.pack(side=TOP)
22069  else:
22070  devx = session.devices[0]
22071  # devx.ignore_dataflow = True
22072  devx.set_led(0b010) # if only one board set LED.green
22073  try:
22074  FWRevOne = float(devx.fwver)
22075  HWRevOne = devx.hwver
22076  except:
22077  FWRevOne = "Before 2.06"
22078  HWRevOne = "?"
22079  dev0 = session.devices[0]
22080 #
22082  global boardwindow, BoardStatus
22083 
22084  BoardStatus.set(0)
22085  boardwindow.destroy()
22086 #
22088  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
22089  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
22090 
22091  if DevID == "No Device" or DevID == "m1k":
22092  #print("Request sample rate: " + str(SAMPLErate))
22093  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
22094  # session.add_all()
22095  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
22096  if not session.devices:
22097  print( 'No Device plugged IN!')
22098  DevID = "No Device"
22099  FWRevOne = 0.0
22100  HWRevOne = "?"
22101  bcon.configure(text="Recon", style="RConn.TButton")
22102  return
22103  session.configure(sample_rate=SAMPLErate)
22104  # print("Session sample rate: " + str(session.sample_rate))
22105  MakeBoardScreen()
22106  SelectBoard()
22107  bcon.configure(text="Conn", style="GConn.TButton")
22108  devx.set_adc_mux(0)
22109  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
22110  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
22111 
22115  session.start(0)
22116 #
22118  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
22119  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
22120  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
22121 
22122  if RUNstatus.get() == 1:
22123  BStop()
22124  print( "STOP")
22125 
22126  if BrdSel.get() == 0:
22127  try:
22128  session.remove(dev1)
22129  print( "Removing dev1")
22130  except:
22131  print( "Skipping dev1")
22132  try:
22133  session.remove(dev2)
22134  print( "Removing dev2")
22135  except:
22136  print( "Skipping dev2")
22137  session.add(dev0)
22138  devx = dev0
22139  #session.add(devx)
22140  if BrdSel.get() == 1:
22141  try:
22142  session.remove(dev0)
22143  print( "Removing dev0")
22144  except:
22145  print( "Skipping dev0")
22146  try:
22147  session.remove(dev2)
22148  print( "Removing dev2")
22149  except:
22150  print( "Skipping dev2")
22151  session.add(dev1)
22152  devx = dev1
22153  #session.add(devx)
22154  DevID = devx.serial
22155  print( DevID)
22156  FWRevOne = float(devx.fwver)
22157  HWRevOne = str(devx.hwver)
22158  print( FWRevOne, HWRevOne)
22159  # print("Session sample rate: " + str(session.sample_rate))
22160 
22161  if IgnoreFirmwareCheck == 0:
22162  if FWRevOne < 2.17:
22163  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
22164  UpdateFirmware()
22165  cal = devx.calibration
22166  CHA = devx.channels['A'] # Open CHA
22167  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
22168  CHB = devx.channels['B'] # Open CHB
22169  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
22170  #
22171  # if session.continuous == 0:
22172  #session.start(0)
22173 
22182  devx.set_adc_mux(0)
22183  if devx.hwver == "F":
22184  print( "Rev F Board I/O ports set")
22185  PIO_0 = 28
22186  PIO_1 = 29
22187  PIO_2 = 47
22188  PIO_3 = 3
22189  PIO_4 = 4
22190  PIO_5 = 5
22191  PIO_6 = 6
22192  PIO_7 = 7
22193  else:
22194  PIO_0 = 0
22195  PIO_1 = 1
22196  PIO_2 = 2
22197  PIO_3 = 3
22198  PIO_4 = 4
22199  PIO_5 = 5
22200  PIO_6 = 6
22201  PIO_7 = 7
22202 #
22203  SDATAPort.set(PIO_1)
22204  SCLKPort.set(PIO_2)
22205  SLATCHPort.set(PIO_0)
22206 
22208  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
22209  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
22210  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
22211  global FrameRefief, BorderSize
22212 
22213  if SampleRateStatus.get() == 0:
22214  SampleRateStatus.set(1)
22215  SampleRatewindow = Toplevel()
22216  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
22217  SampleRatewindow.resizable(FALSE,FALSE)
22218  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
22219  frame1 = Frame(SampleRatewindow, borderwidth=BorderSize, relief=FrameRefief)
22220  frame1.grid(row=0, column=0, sticky=W)
22221  #
22222  BaseRATE = Frame( frame1 )
22223  BaseRATE.grid(row=0, column=0, sticky=W)
22224  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
22225  baseratelab.pack(side=LEFT)
22226  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
22227  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
22228  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
22229  BaseRatesb.bind("<Button-5>", onSrateScroll)
22230  BaseRatesb.bind("<Return>", onRetSrate)
22231  BaseRatesb.pack(side=LEFT)
22232  BaseRatesb.delete(0,"end")
22233  BaseRatesb.insert(0,BaseSampleRate)
22234  #
22235  nextrow = 2
22236  if FWRevOne > 2.16:
22237  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
22238  twoX.grid(row=1, column=0, sticky=W)
22239  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
22240  muxlab1.grid(row=2, column=0, sticky=W)
22241  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
22242  AltSweep.grid(row=3, column=0, sticky=W)
22243  chabuttons = Frame( frame1 )
22244  chabuttons.grid(row=4, column=0, sticky=W)
22245  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
22246  muxrb1.pack(side=LEFT)
22247  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
22248  muxrb2.pack(side=LEFT)
22249  chcbuttons = Frame( frame1 )
22250  chcbuttons.grid(row=5, column=0, sticky=W)
22251  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
22252  muxrb5.pack(side=LEFT)
22253  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
22254  muxrb6.pack(side=LEFT)
22255  nextrow = 6
22256  if DeBugMode == 1:
22257  chbbuttons = Frame( frame1 )
22258  chbbuttons.grid(row=nextrow, column=0, sticky=W)
22259  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
22260  muxrb3.pack(side=LEFT)
22261  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
22262  muxrb4.pack(side=LEFT)
22263  nextrow = nextrow + 1
22264  #
22265  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
22266  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
22267 #
22269  global SampleRatewindow, SampleRateStatus
22270 
22271  SampleRateStatus.set(0)
22272  SampleRatewindow.destroy()
22273 #
22274 #
22275 def onSrateScroll(event):
22276 
22277  #onTextScroll
22278  onSpinBoxScroll(event)
22279  SetSampleRate()
22280 #
22281 def onRetSrate(event):
22282 
22283  SetSampleRate()
22284 #
22286  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
22287  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
22288 
22289  #
22290  WasRunning = 0
22291  if (RUNstatus.get() == 1):
22292  WasRunning = 1
22293  BStop() # Force Stop loop if running
22294  try:
22295  NewRate = int(BaseRatesb.get())
22296  if NewRate <= 100000: # rate has to be less than or equal to 100,000
22297  BaseSampleRate = NewRate
22298  else:
22299  BaseSampleRate = 100000
22300  BaseRatesb.delete(0,"end")
22301  BaseRatesb.insert(0,BaseSampleRate)
22302  SAMPLErate = BaseSampleRate # Scope sample rate
22303  except:
22304  donothing()
22305  session.configure(sample_rate=BaseSampleRate)
22306  BaseSampleRate = session.sample_rate
22307  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
22308  SAMPLErate = BaseSampleRate # Scope sample rate
22309  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
22310  AWGSAMPLErate = BaseSampleRate
22311  if ETSStatus.get() > 0:
22312  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
22313  rtsrlab.config(text=SRstring)
22314  ETSUpdate()
22315  BaseRatesb.delete(0,"end")
22316  BaseRatesb.insert(0,BaseSampleRate)
22317  ReMakeAWGwaves() # remake AWG waveforms for new rate
22318  if (WasRunning == 1):
22319  WasRunning = 0
22320  BStart() # restart loop if was running
22321 #
22322 def onStopfreqScroll(event):
22323  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22324 
22325  onTextScroll(event)
22326  try:
22327  StopFrequency = float(StopFreqEntry.get())
22328  except:
22329  StopFreqEntry.delete(0,"end")
22330  StopFreqEntry.insert(0,50000)
22331  StopFrequency = 50000
22332  if FWRevOne > 2.16:
22333  if StopFrequency >= 50000:
22334  Two_X_Sample.set(1)
22335  ADC_Mux_Mode.set(0)
22336  SetADC_Mux()
22337  else:
22338  Two_X_Sample.set(0)
22339  ADC_Mux_Mode.set(0)
22340  SetADC_Mux()
22341 #
22342 def onStopBodeScroll(event):
22343  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22344 
22345  onTextScroll(event)
22346  try:
22347  StopFrequency = float(StopBodeEntry.get())
22348  except:
22349  StopBodeEntry.delete(0,"end")
22350  StopBodeEntry.insert(0,20000)
22351  StopFrequency = 20000
22352  if FWRevOne > 2.16:
22353  if StopFrequency >= 20000:
22354  Two_X_Sample.set(1)
22355  ADC_Mux_Mode.set(0)
22356  SetADC_Mux()
22357  else:
22358  Two_X_Sample.set(0)
22359  ADC_Mux_Mode.set(0)
22360  SetADC_Mux()
22361 #
22363  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
22364  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
22365  global AWGSync, discontloop, session, ADsignal1
22366 
22367  if Two_X_Sample.get() == 1:
22368  if ADC_Mux_Mode.get() == 0: # VA and VB
22369  devx.set_adc_mux(1)
22370  elif ADC_Mux_Mode.get() == 1: # IA and IB
22371  devx.set_adc_mux(2)
22372  elif ADC_Mux_Mode.get() == 2: # VA and IB
22373  # cycle trhough default mux values as starting point
22374  devx.set_adc_mux(2)
22375  # now set new mux values
22376  devx.set_adc_mux(7)
22377  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22378  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22379  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22380  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22381  time.sleep(0.1)
22382  elif ADC_Mux_Mode.get() == 3: # VB and IA
22383  # cycle trhough default mux values as starting point
22384  # now set new mux values
22385  devx.set_adc_mux(7)
22386  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22387  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22388  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22389  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22390  time.sleep(0.1)
22391  elif ADC_Mux_Mode.get() == 4: # VA and IA
22392  # cycle trhough default mux values as starting point
22393  devx.set_adc_mux(2)
22394  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22395  if discontloop > 0:
22396  session.flush()
22397  else:
22398  discontloop = 1
22399  time.sleep(0.01)
22400  BAWGEnab()
22401  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22402 
22403  else: # running in continuous mode
22404  if session.continuous:
22405  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22406  # now set new mux values
22407  devx.set_adc_mux(4)
22408  elif ADC_Mux_Mode.get() == 5: # VB and IB
22409  # cycle trhough default mux values as starting point
22410  devx.set_adc_mux(2)
22411  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22412  if discontloop > 0:
22413  session.flush()
22414  else:
22415  discontloop = 1
22416  time.sleep(0.01)
22417  BAWGEnab()
22418  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22419 
22420  else: # running in continuous mode
22421  if session.continuous:
22422  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22423  # now set new mux values
22424  devx.set_adc_mux(5)
22425  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
22426  else:
22427  devx.set_adc_mux(0)
22428  SAMPLErate = BaseSampleRate
22429 #
22431  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
22432 
22433  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22434  ADC_Mux_Mode.set(0) # All four traces
22435  Alternate_Sweep_Mode.set(1)
22436  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
22437  ADC_Mux_Mode.set(0) # three traces
22438  Alternate_Sweep_Mode.set(1)
22439  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22440  ADC_Mux_Mode.set(0) # three traces
22441  Alternate_Sweep_Mode.set(1)
22442  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22443  ADC_Mux_Mode.set(0) # three traces
22444  Alternate_Sweep_Mode.set(1)
22445  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22446  ADC_Mux_Mode.set(0) # three traces
22447  Alternate_Sweep_Mode.set(1)
22448  #
22449  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22450  ADC_Mux_Mode.set(1) # IA and IB
22451  Alternate_Sweep_Mode.set(0)
22452  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22453  ADC_Mux_Mode.set(1) # just IA
22454  Alternate_Sweep_Mode.set(0)
22455  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22456  ADC_Mux_Mode.set(1) # just IB
22457  Alternate_Sweep_Mode.set(0)
22458  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22459  ADC_Mux_Mode.set(4) # VA and IA
22460  Alternate_Sweep_Mode.set(0)
22461  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22462  ADC_Mux_Mode.set(5) # VB and IB
22463  Alternate_Sweep_Mode.set(0)
22464  else:
22465  ADC_Mux_Mode.set(0)
22466  Alternate_Sweep_Mode.set(0)
22467  SetADC_Mux()
22468  UpdateTimeTrace()
22469 #
22471  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
22472  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22473 
22474  RUNstatus.set(0)
22475  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
22476  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
22477  print( filename)
22478  #print DevID
22479  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
22480  try:
22481  print( "Cancel current session.")
22482  session.cancel()
22483  print( session.cancelled)
22484  session.end()
22485  print( "Waiting 5...")
22486  time.sleep(5)
22487  print( "Put board in Samba mode and flash firmware.")
22488  session.flash_firmware(filename)
22489  except:
22490  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22491 
22499  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22500  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
22501  Bcloseexit()
22502 
22512  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
22513  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
22514  global FrameRefief, BorderSize
22515 
22516  if OhmStatus.get() == 0:
22517  AWGSync.set(1)
22518  OhmStatus.set(1)
22519  OhmDisp.set(1)
22520  OhmCheckBox()
22521  ohmwindow = Toplevel()
22522  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
22523  ohmwindow.resizable(FALSE,FALSE)
22524  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
22525  frame1 = Frame(ohmwindow, borderwidth=BorderSize, relief=FrameRefief)
22526  frame1.grid(row=0, column=0, sticky=W)
22527  #
22528  buttons = Frame( frame1 )
22529  buttons.grid(row=0, column=0, sticky=W)
22530  omrb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
22531  omrb2.pack(side=LEFT)
22532  omrb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
22533  omrb1.pack(side=LEFT)
22534  #
22535  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
22536  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
22537  OhmA0.config(text = "0.000 Ohms")
22538 
22539  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
22540  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
22541  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
22542  #
22543  TestVA = Frame( frame1 )
22544  TestVA.grid(row=3, column=0, sticky=W)
22545  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
22546  chatestvlab.pack(side=LEFT)
22547  CHATestVEntry = Entry(TestVA, width=6, cursor='double_arrow') #
22548  CHATestVEntry.pack(side=LEFT)
22549  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
22550  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22551  CHATestVEntry.bind("<Button-5>", onTextScroll)
22552  CHATestVEntry.delete(0,"end")
22553  CHATestVEntry.insert(0,5.0)
22554  #
22555  RMode = IntVar(0)
22556  RMode.set(1)
22557  TestMode = Frame( frame1 )
22558  TestMode.grid(row=4, column=0, sticky=W)
22559  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22560  modelab.pack(side=LEFT)
22561  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
22562  rm3.pack(side=LEFT)
22563  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
22564  rm4.pack(side=LEFT)
22565  #
22566  TestRA = Frame( frame1 )
22567  TestRA.grid(row=5, column=0, sticky=W)
22568  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22569  chatestrlab.pack(side=LEFT)
22570  CHATestREntry = Entry(TestRA, width=6, cursor='double_arrow') #
22571  CHATestREntry.pack(side=LEFT)
22572  CHATestREntry.bind('<MouseWheel>', onTextScroll)
22573  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
22574  CHATestREntry.bind("<Button-5>", onTextScroll)
22575  CHATestREntry.delete(0,"end")
22576  CHATestREntry.insert(0,OnBoardRes)
22577  #
22578  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
22579  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
22580 #
22582  global ohmwindow, OhmStatus, OhmDisp
22583 
22584  OhmStatus.set(0)
22585  OhmDisp.set(0)
22586  OhmCheckBox()
22587  ohmwindow.destroy()
22588 #
22590  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
22591  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
22592  global MinigenScreenStatus, DeBugMode
22593  global FrameRefief, BorderSize
22594 
22595  #
22596  if ETSStatus.get() == 0:
22597  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
22598  ETSStatus.set(1)
22599  ETSDisp.set(0)
22600  etswindow = Toplevel()
22601  etswindow.title("ETS Controls " + SWRev + RevDate)
22602  etswindow.resizable(FALSE,FALSE)
22603  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
22604  frame1 = Frame(etswindow, borderwidth=BorderSize, relief=FrameRefief)
22605  frame1.grid(row=0, column=0, sticky=W)
22606  # Sampling controls Widgets
22607  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22608  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22609  rtsrlab.grid(row=1, column=0, sticky=W)
22610  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
22611  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22612  etssrlab.grid(row=2, column=0, sticky=W)
22613  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
22614  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
22615  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
22616  enb1.grid(row=4, column=0, sticky=W)
22617  #
22618  Divx = Frame( frame1 )
22619  Divx.grid(row=5, column=0, sticky=W)
22620  DivXEntry = Entry(Divx, width=6, cursor='double_arrow')
22621  DivXEntry.bind('<MouseWheel>', ETSscroll)
22622  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22623  DivXEntry.bind("<Button-5>", ETSscroll)
22624  DivXEntry.pack(side=RIGHT)
22625  DivXEntry.delete(0,"end")
22626  DivXEntry.insert(0,2)
22627  divxlab = Label( Divx, text = "Divide Factor")
22628  divxlab.pack(side=RIGHT)
22629  GridRow = 5
22630  #
22631  if DeBugMode > 0:
22632  FOffEntry = Label(frame1, text="Samples")
22633  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
22634  MulXEntry = Label( frame1, text = "Rec Len Mul")
22635  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
22636  GridRow = GridRow + 2
22637  #
22638  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
22639  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
22640  #
22641  FConv = Frame( frame1 )
22642  FConv.grid(row=GridRow+2, column=0, sticky=W)
22643  FMulXEntry = Entry(FConv, width=3, cursor='double_arrow')
22644  FMulXEntry.bind('<MouseWheel>', ETSscroll)
22645  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22646  FMulXEntry.bind("<Button-5>", ETSscroll)
22647  FMulXEntry.pack(side=RIGHT)
22648  FMulXEntry.delete(0,"end")
22649  FMulXEntry.insert(0,1)
22650  fminlab = Label( FConv, text = "Freq Multiplier")
22651  fminlab.pack(side=RIGHT)
22652  #
22653  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
22654  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
22655  #
22656  if MinigenScreenStatus.get() > 0:
22657  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
22658  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
22659  GridRow = GridRow + 1
22660  #
22661  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
22662  dirlab.grid(row=GridRow+5, column=0, sticky=W)
22663  DataMode = Frame( frame1 )
22664  DataMode.grid(row=GridRow+6, column=0, sticky=W)
22665  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
22666  dm3.pack(side=LEFT)
22667  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
22668  dm4.pack(side=LEFT)
22669  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
22670  tclab.grid(row=GridRow+7, column=0, sticky=W)
22671  TSMode = Frame( frame1 )
22672  TSMode.grid(row=GridRow+8, column=0, sticky=W)
22673  ETSts = Entry(TSMode, width=6, cursor='double_arrow')
22674  ETSts.bind('<MouseWheel>', ETSscroll)
22675  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
22676  ETSts.bind("<Button-5>", ETSscroll)
22677  ETSts.pack(side=RIGHT)
22678  ETSts.delete(0,"end")
22679  ETSts.insert(0,1)
22680  ETStslab = Label( TSMode, text = "Factor")
22681  ETStslab.pack(side=RIGHT)
22682  #
22683  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
22684  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
22685  ETSDisp.set(0)
22686  ETSCheckBox()
22687 #
22689  global etswindow, ETSStatus, ETSDisp
22690 
22691  ETSStatus.set(0)
22692  ETSDisp.set(0)
22693  ETSCheckBox()
22694  etswindow.destroy()
22695 #
22696 def MGLoad():
22697  global MinigenFout, Fmin, ETSDir
22698 
22699  MinigenFout.delete(0,"end")
22700  if ETSDir.get() == 0:
22701  MinigenFout.insert(0,Fmin+20)
22702  else:
22703  MinigenFout.insert(0,Fmin-20)
22704  BSendMG()
22705 #
22706 def ETSscroll(event):
22707  onTextScroll(event)
22708  ETSUpdate()
22709 #
22710 def onFminScroll(event):
22711  onTextScroll(event)
22712  ETSUpdate()
22713  SetETSComp()
22714  SetAD9833(event)
22715 
22716 def onMulXScroll(event):
22717  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
22718 
22719  onTextScroll(event)
22720  # ETSUpdate()
22721  try:
22722  TscaleX = float(HtMulEntry.get())
22723  except:
22724  HtMulEntry.delete(0,END)
22725  HtMulEntry.insert(0, 1)
22726  if Two_X_Sample.get() == 0:
22727  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22728  else:
22729  ToffsetX = 0
22730  ETSts.delete(0,"end")
22731  ETSts.insert(0,ToffsetX)
22732  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22733  etssrlab.config(text=SRstring)
22734  #
22735  SetETSComp()
22736  SetAD9833(event)
22737 #
22739  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
22740  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
22741  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
22742 
22743  if TIMEdiv > 0.2:
22744  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
22745  else:
22746  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
22747  if (MaxETSrecord*100) > MaxSamples:
22748  MaxETSrecord = MaxSamples / 100
22749  try:
22750  DivX = float(eval(DivXEntry.get()))
22751  if DivX < 2:
22752  DivX = 2
22753  if DivX > 75:
22754  DivX = 75
22755  DivXEntry.delete(0,END)
22756  DivXEntry.insert(0, DivX)
22757  except:
22758  DivXEntry.delete(0,END)
22759  DivXEntry.insert(0, DivX)
22760  #
22761  FOff = 25
22762  MulX = (DivX*SAMPLErate)/(100*FOff)
22763  while MulX > MaxETSrecord:
22764  FOff = FOff + 5
22765  MulX = (DivX*SAMPLErate)/(100*FOff)
22766  FOff = 0 - FOff
22767  if DeBugMode > 0:
22768  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
22769  MulXEntry.config(text = SRstring) # change displayed value
22770  SRstring = "Offset = " + str(FOff) + " samples"
22771  FOffEntry.config(text = SRstring) # change displayed value
22772  baseFreq = SAMPLErate/DivX
22773  try:
22774  FMul = float(eval(FMulXEntry.get()))
22775  if FMul < 1:
22776  FMul = 1
22777  FMulXEntry.delete(0,END)
22778  FMulXEntry.insert(0, int(FMul))
22779  if FMul > 75:
22780  FMul = 75
22781  FMulXEntry.delete(0,END)
22782  FMulXEntry.insert(0, int(FMul))
22783  except:
22784  FMulXEntry.delete(0,END)
22785  FMulXEntry.insert(0, int(FMul))
22786  FreqMin = baseFreq * FMul
22787  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
22788  FminDisp.config(text = SRstring) # change displayed value
22789  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
22790  eqivsamplerate.config(text = SRstring) # change displayed value
22791  # calculate time scale multiplication factor
22792  try:
22793  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
22794  except:
22795  FminEntry.delete(0,END)
22796  FminEntry.insert(0, 25)
22797  #
22798  try: # catch for divide by zero
22799  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
22800  except:
22801  TscaleX = 1
22802 
22803  if TscaleX > 0:
22804  ETSDir.set(0) # set sample direction to forward if positive
22805  else:
22806  ETSDir.set(1) # set sample direction to reverse if negative
22807  TscaleX = abs(TscaleX)
22808  if Two_X_Sample.get() == 0:
22809  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22810  else:
22811  ToffsetX = 0
22812  ETSts.delete(0,"end")
22813  ETSts.insert(0,ToffsetX)
22814 
22815  HtMulEntry.delete(0,END)
22816  HtMulEntry.insert(0, TscaleX)
22817  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22818  rtsrlab.config(text=SRstring)
22819  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22820  etssrlab.config(text=SRstring)
22821 #
22822 def Settingsscroll(event):
22823  onTextScroll(event)
22824  SettingsUpdate()
22825 #
22826 def SettingsTextKey(event):
22827  onTextKey(event)
22828  SettingsUpdate()
22829 #
22831  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
22832  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
22833  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
22834  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
22835  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
22836  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
22837  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
22838  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
22839  global FrameRefief, BorderSize
22840 
22841  if SettingsStatus.get() == 0:
22842  SettingsStatus.set(1)
22843  Settingswindow = Toplevel()
22844  Settingswindow.title("Settings " + SWRev + RevDate)
22845  Settingswindow.resizable(FALSE,FALSE)
22846  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
22847  frame1 = Frame(Settingswindow, borderwidth=BorderSize, relief=FrameRefief)
22848  frame1.grid(row=0, column=0, sticky=W)
22849  #
22850  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
22851  zstlab.grid(row=0, column=0, sticky=W)
22852  zstMode = Frame( frame1 )
22853  zstMode.grid(row=0, column=1, sticky=W)
22854  ZSTuff = Entry(zstMode, width=4, cursor='double_arrow')
22855  ZSTuff.bind("<Return>", SettingsTextKey)
22856  ZSTuff.bind('<MouseWheel>', Settingsscroll)
22857  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
22858  ZSTuff.bind("<Button-5>", Settingsscroll)
22859  ZSTuff.bind('<Key>', SettingsTextKey)
22860  ZSTuff.pack(side=RIGHT)
22861  ZSTuff.delete(0,"end")
22862  ZSTuff.insert(0,ZEROstuffing.get())
22863  #
22864  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
22865  Avglab.grid(row=1, column=0, sticky=W)
22866  AvgMode = Frame( frame1 )
22867  AvgMode.grid(row=1, column=1, sticky=W)
22868  TAvg = Entry(AvgMode, width=4, cursor='double_arrow')
22869  TAvg.bind("<Return>", SettingsTextKey)
22870  TAvg.bind('<MouseWheel>', Settingsscroll)
22871  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
22872  TAvg.bind("<Button-5>", Settingsscroll)
22873  TAvg.bind('<Key>', SettingsTextKey)
22874  TAvg.pack(side=RIGHT)
22875  TAvg.delete(0,"end")
22876  TAvg.insert(0,TRACEaverage.get())
22877  #
22878  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
22879  HarMlab.grid(row=2, column=0, sticky=W)
22880  HarMMode = Frame( frame1 )
22881  HarMMode.grid(row=2, column=1, sticky=W)
22882  HarMon = Entry(HarMMode, width=4, cursor='double_arrow')
22883  HarMon.bind("<Return>", SettingsTextKey)
22884  HarMon.bind('<MouseWheel>', Settingsscroll)
22885  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
22886  HarMon.bind("<Button-5>", Settingsscroll)
22887  HarMon.bind('<Key>', SettingsTextKey)
22888  HarMon.pack(side=RIGHT)
22889  HarMon.delete(0,"end")
22890  HarMon.insert(0,HarmonicMarkers.get())
22891  #
22892  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
22893  Vdivlab.grid(row=3, column=0, sticky=W)
22894  VdivMode = Frame( frame1 )
22895  VdivMode.grid(row=3, column=1, sticky=W)
22896  VDivE = Entry(VdivMode, width=4, cursor='double_arrow')
22897  VDivE.bind("<Return>", SettingsTextKey)
22898  VDivE.bind('<MouseWheel>', Settingsscroll)
22899  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
22900  VDivE.bind("<Button-5>", Settingsscroll)
22901  VDivE.bind('<Key>', SettingsTextKey)
22902  VDivE.pack(side=RIGHT)
22903  VDivE.delete(0,"end")
22904  VDivE.insert(0,Vdiv.get())
22905  #
22906  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
22907  Twdthlab.grid(row=4, column=0, sticky=W)
22908  TwdthMode = Frame( frame1 )
22909  TwdthMode.grid(row=4, column=1, sticky=W)
22910  TwdthE = Entry(TwdthMode, width=4, cursor='double_arrow')
22911  TwdthE.bind("<Return>", SettingsTextKey)
22912  TwdthE.bind('<MouseWheel>', Settingsscroll)
22913  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22914  TwdthE.bind("<Button-5>", Settingsscroll)
22915  TwdthE.bind('<Key>', SettingsTextKey)
22916  TwdthE.pack(side=RIGHT)
22917  TwdthE.delete(0,"end")
22918  TwdthE.insert(0,TRACEwidth.get())
22919  #
22920  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
22921  Gwdthlab.grid(row=5, column=0, sticky=W)
22922  GwdthMode = Frame( frame1 )
22923  GwdthMode.grid(row=5, column=1, sticky=W)
22924  GwdthE = Entry(GwdthMode, width=4, cursor='double_arrow')
22925  GwdthE.bind("<Return>", SettingsTextKey)
22926  GwdthE.bind('<MouseWheel>', Settingsscroll)
22927  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22928  GwdthE.bind("<Button-5>", Settingsscroll)
22929  GwdthE.bind('<Key>', SettingsTextKey)
22930  GwdthE.pack(side=RIGHT)
22931  GwdthE.delete(0,"end")
22932  GwdthE.insert(0,GridWidth.get())
22933  #
22934  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
22935  trglpflab.grid(row=6, column=0, sticky=W)
22936  TrgLPFMode = Frame( frame1 )
22937  TrgLPFMode.grid(row=6, column=1, sticky=W)
22938  TrgLPFEntry = Entry(TrgLPFMode, width=4, cursor='double_arrow')
22939  TrgLPFEntry.bind("<Return>", SettingsTextKey)
22940  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
22941  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
22942  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
22943  TrgLPFEntry.bind('<Key>', SettingsTextKey)
22944  TrgLPFEntry.pack(side=RIGHT)
22945  TrgLPFEntry.delete(0,"end")
22946  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
22947  #
22948  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
22949  AwgAmplrb1.grid(row=7, column=0, sticky=W)
22950  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
22951  AwgAmplrb2.grid(row=7, column=1, sticky=W)
22952  #
22953  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22954  cha_Rcomplab.grid(row=8, column=0, sticky=W)
22955  cha_RcomplabMode = Frame( frame1 )
22956  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
22957  cha_TC1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22958  cha_TC1Entry.bind("<Return>", SettingsTextKey)
22959  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22960  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22961  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
22962  cha_TC1Entry.bind('<Key>', SettingsTextKey)
22963  cha_TC1Entry.pack(side=LEFT)
22964  cha_TC1Entry.delete(0,"end")
22965  cha_TC1Entry.insert(0,CHA_TC1.get())
22966  cha_A1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22967  cha_A1Entry.bind("<Return>", SettingsTextKey)
22968  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
22969  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22970  cha_A1Entry.bind("<Button-5>", Settingsscroll)
22971  cha_A1Entry.bind('<Key>', SettingsTextKey)
22972  cha_A1Entry.pack(side=LEFT)
22973  cha_A1Entry.delete(0,"end")
22974  cha_A1Entry.insert(0,CHA_A1.get())
22975  #
22976  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22977  cha_Ccomplab.grid(row=9, column=0, sticky=W)
22978  cha_CcomplabMode = Frame( frame1 )
22979  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
22980  cha_TC2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22981  cha_TC2Entry.bind("<Return>", SettingsTextKey)
22982  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22983  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22984  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
22985  cha_TC2Entry.bind('<Key>', SettingsTextKey)
22986  cha_TC2Entry.pack(side=LEFT)
22987  cha_TC2Entry.delete(0,"end")
22988  cha_TC2Entry.insert(0,CHA_TC2.get())
22989  cha_A2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22990  cha_A2Entry.bind("<Return>", SettingsTextKey)
22991  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
22992  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22993  cha_A2Entry.bind("<Button-5>", Settingsscroll)
22994  cha_A2Entry.bind('<Key>', SettingsTextKey)
22995  cha_A2Entry.pack(side=LEFT)
22996  cha_A2Entry.delete(0,"end")
22997  cha_A2Entry.insert(0,CHA_A2.get())
22998  #
22999  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23000  chb_Rcomplab.grid(row=10, column=0, sticky=W)
23001  chb_RcomplabMode = Frame( frame1 )
23002  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
23003  chb_TC1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
23004  chb_TC1Entry.bind("<Return>", SettingsTextKey)
23005  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23006  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23007  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
23008  chb_TC1Entry.bind('<Key>', SettingsTextKey)
23009  chb_TC1Entry.pack(side=LEFT)
23010  chb_TC1Entry.delete(0,"end")
23011  chb_TC1Entry.insert(0,CHB_TC1.get())
23012  chb_A1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
23013  chb_A1Entry.bind("<Return>", SettingsTextKey)
23014  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
23015  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23016  chb_A1Entry.bind("<Button-5>", Settingsscroll)
23017  chb_A1Entry.bind('<Key>', SettingsTextKey)
23018  chb_A1Entry.pack(side=LEFT)
23019  chb_A1Entry.delete(0,"end")
23020  chb_A1Entry.insert(0,CHB_A1.get())
23021  #
23022  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23023  chb_Ccomplab.grid(row=11, column=0, sticky=W)
23024  chb_CcomplabMode = Frame( frame1 )
23025  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
23026  chb_TC2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
23027  chb_TC2Entry.bind("<Return>", SettingsTextKey)
23028  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23029  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23030  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
23031  chb_TC2Entry.bind('<Key>', SettingsTextKey)
23032  chb_TC2Entry.pack(side=LEFT)
23033  chb_TC2Entry.delete(0,"end")
23034  chb_TC2Entry.insert(0,CHB_TC2.get())
23035  chb_A2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
23036  chb_A2Entry.bind("<Return>", SettingsTextKey)
23037  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
23038  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23039  chb_A2Entry.bind("<Button-5>", Settingsscroll)
23040  chb_A2Entry.bind('<Key>', SettingsTextKey)
23041  chb_A2Entry.pack(side=LEFT)
23042  chb_A2Entry.delete(0,"end")
23043  chb_A2Entry.insert(0,CHB_A2.get())
23044  #
23045  if EnableHSsampling > 0:
23046  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
23047  hs_ckb1.grid(row=12, column=0, sticky=W)
23048  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
23049  hs1_Complab.grid(row=13, column=0, sticky=W)
23050  hs1_ComplabMode = Frame( frame1 )
23051  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
23052  ets_TC1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23053  ets_TC1Entry.bind("<Return>", SettingsTextKey)
23054  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
23055  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23056  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
23057  ets_TC1Entry.bind('<Key>', SettingsTextKey)
23058  ets_TC1Entry.pack(side=LEFT)
23059  ets_TC1Entry.delete(0,"end")
23060  ets_TC1Entry.insert(0,ETS_TC1.get())
23061  ets_A1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
23062  ets_A1Entry.bind("<Return>", SettingsTextKey)
23063  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
23064  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23065  ets_A1Entry.bind("<Button-5>", Settingsscroll)
23066  ets_A1Entry.bind('<Key>', SettingsTextKey)
23067  ets_A1Entry.pack(side=LEFT)
23068  ets_A1Entry.delete(0,"end")
23069  ets_A1Entry.insert(0,ETS_A1.get())
23070  #
23071  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
23072  hs2_Complab.grid(row=14, column=0, sticky=W)
23073  hs2_ComplabMode = Frame( frame1 )
23074  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
23075  ets_TC2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23076  ets_TC2Entry.bind("<Return>", SettingsTextKey)
23077  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
23078  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23079  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
23080  ets_TC2Entry.bind('<Key>', SettingsTextKey)
23081  ets_TC2Entry.pack(side=LEFT)
23082  ets_TC2Entry.delete(0,"end")
23083  ets_TC2Entry.insert(0,ETS_TC2.get())
23084  ets_A2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
23085  ets_A2Entry.bind("<Return>", SettingsTextKey)
23086  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
23087  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
23088  ets_A2Entry.bind("<Button-5>", Settingsscroll)
23089  ets_A2Entry.bind('<Key>', SettingsTextKey)
23090  ets_A2Entry.pack(side=LEFT)
23091  ets_A2Entry.delete(0,"end")
23092  ets_A2Entry.insert(0,ETS_A2.get())
23093  #
23094  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23095  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
23096  else:
23097  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
23098  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
23099 #
23101  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
23102  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
23103  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23104  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23105  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23106  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23107 
23108  if Auto_ETS_Comp.get() == 1:
23109  try:
23110  MulX = float(HtMulEntry.get())
23111  #
23112  Value = float(ets_TC1Entry.get()) * MulX
23113  cha_TC1Entry.delete(0,"end")
23114  cha_TC1Entry.insert(0, Value)
23115  cha_A1Entry.delete(0,"end")
23116  cha_A1Entry.insert(0, ets_A1Entry.get())
23117  chb_TC1Entry.delete(0,"end")
23118  chb_TC1Entry.insert(0, Value)
23119  chb_A1Entry.delete(0,"end")
23120  chb_A1Entry.insert(0, ets_A1Entry.get())
23121  #
23122  Value = float(ets_TC2Entry.get()) * MulX
23123  cha_TC2Entry.delete(0,"end")
23124  cha_TC2Entry.insert(0, Value)
23125  cha_A2Entry.delete(0,"end")
23126  cha_A2Entry.insert(0, ets_A2Entry.get())
23127  chb_TC2Entry.delete(0,"end")
23128  chb_TC2Entry.insert(0, Value)
23129  chb_A2Entry.delete(0,"end")
23130  chb_A2Entry.insert(0, ets_A2Entry.get())
23131  except:
23132  MulX = 1.0
23133 
23135 
23136  UpdateAWGA()
23137  UpdateAWGB()
23138  ReMakeAWGwaves()
23139 
23141  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23142  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23143  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23144  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
23145  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23146  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23147 
23148  try:
23149  GW = int(eval(GwdthE.get()))
23150  if GW < 1:
23151  GW = 1
23152  GwdthE.delete(0,END)
23153  GwdthE.insert(0, int(GW))
23154  if GW > 5:
23155  GW = 5
23156  GwdthE.delete(0,END)
23157  GwdthE.insert(0, int(GW))
23158  except:
23159  GwdthE.delete(0,END)
23160  GwdthE.insert(0, GridWidth.get())
23161  GridWidth.set(GW)
23162  #
23163  try:
23164  T_length = int(eval(TrgLPFEntry.get()))
23165  if T_length < 1:
23166  T_length = 1
23167  TrgLPFEntry.delete(0,END)
23168  TrgLPFEntry.insert(0, int(GW))
23169  if T_length > 100:
23170  T_length = 100
23171  TrgLPFEntry.delete(0,END)
23172  TrgLPFEntry.insert(0, int(GW))
23173  except:
23174  TrgLPFEntry.delete(0,END)
23175  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
23176  Trigger_LPF_length.set(T_length)
23177  #
23178  try:
23179  TW = int(eval(TwdthE.get()))
23180  if TW < 1:
23181  TW = 1
23182  TwdthE.delete(0,END)
23183  TwdthE.insert(0, int(TW))
23184  if TW > 5:
23185  TW = 5
23186  TwdthE.delete(0,END)
23187  TwdthE.insert(0, int(TW))
23188  except:
23189  TwdthE.delete(0,END)
23190  TwdthE.insert(0, TRACEwidth.get())
23191  TRACEwidth.set(TW)
23192  # Number of average sweeps for average mode
23193  try:
23194  TA = int(eval(TAvg.get()))
23195  if TA < 1:
23196  TA = 1
23197  TAvg.delete(0,END)
23198  TAvg.insert(0, int(TA))
23199  if TA > 16:
23200  TA = 16
23201  TAvg.delete(0,END)
23202  TAvg.insert(0, int(TA))
23203  except:
23204  TAvg.delete(0,END)
23205  TAvg.insert(0, TRACEaverage.get())
23206  TRACEaverage.set(TA)
23207  # Number of vertical divisions for spectrum / Bode
23208  try:
23209  VDv = int(eval(VDivE.get()))
23210  if VDv < 1:
23211  VDv = 1
23212  VDivE.delete(0,END)
23213  VDivE.insert(0, int(VDv))
23214  if VDv > 16:
23215  VDv = 16
23216  VDivE.delete(0,END)
23217  VDivE.insert(0, int(VDv))
23218  except:
23219  VDivE.delete(0,END)
23220  VDivE.insert(0, Vdiv.get())
23221  Vdiv.set(VDv)
23222  # number of Harmonic Markers in SA
23223  try:
23224  HM = int(eval(HarMon.get()))
23225  if HM < 1:
23226  HM = 1
23227  HarMon.delete(0,END)
23228  HarMon.insert(0, int(HM))
23229  if HM > 9:
23230  HM =9
23231  HarMon.delete(0,END)
23232  HarMon.insert(0, int(HM))
23233  except:
23234  HarMon.delete(0,END)
23235  HarMon.insert(0, HarmonicMarkers.get())
23236  HarmonicMarkers.set(HM)
23237  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
23238  try:
23239  ZST = int(eval(ZSTuff.get()))
23240  if ZST < 1:
23241  ZST = 1
23242  ZSTuff.delete(0,END)
23243  ZSTuff.insert(0, int(ZST))
23244  if ZST > 5:
23245  ZST = 5
23246  ZSTuff.delete(0,END)
23247  ZSTuff.insert(0, int(ZST))
23248  except:
23249  ZSTuff.delete(0,END)
23250  ZSTuff.insert(0, ZEROstuffing.get())
23251  ZEROstuffing.set(ZST)
23252 #
23253  try:
23254  TC1A = float(cha_TC1Entry.get())
23255  CHA_TC1.set(TC1A)
23256  if TC1A < 0:
23257  TC1A = 0
23258  cha_TC1Entry.delete(0,END)
23259  cha_TC1Entry.insert(0, TC1A)
23260  except:
23261  cha_TC1Entry.delete(0,END)
23262  cha_TC1Entry.insert(0, CHA_TC1.get())
23263  try:
23264  TC2A = float(cha_TC2Entry.get())
23265  CHA_TC2.set(TC2A)
23266  if TC2A < 0:
23267  TC2A = 0
23268  cha_TC2Entry.delete(0,END)
23269  cha_TC2Entry.insert(0, TC2A)
23270  except:
23271  cha_TC2Entry.delete(0,END)
23272  cha_TC2Entry.insert(0, CHA_TC2.get())
23273  #
23274  try:
23275  Gain1A = float(cha_A1Entry.get())
23276  CHA_A1.set(Gain1A)
23277  except:
23278  cha_A1Entry.delete(0,END)
23279  cha_A1Entry.insert(0, CHA_A1.get())
23280  try:
23281  Gain2A = float(cha_A2Entry.get())
23282  CHA_A2.set(Gain2A)
23283  except:
23284  cha_A2Entry.delete(0,END)
23285  cha_A2Entry.insert(0, CHA_A2.get())
23286  #
23287  try:
23288  TC1B = float(chb_TC1Entry.get())
23289  CHB_TC1.set(TC1B)
23290  if TC1B < 0:
23291  TC1B = 0
23292  chb_TC1Entry.delete(0, END)
23293  chb_TC1Entry.insert(0, TC1B)
23294  except:
23295  chb_TC1Entry.delete(0,END)
23296  chb_TC1Entry.insert(0, CHB_TC1.get())
23297  try:
23298  TC2B = float(chb_TC2Entry.get())
23299  CHB_TC2.set(TC2B)
23300  if TC2B < 0:
23301  TC2B = 0
23302  chb_TC2Entry.delete(0, END)
23303  chb_TC2Entry.insert(0, TC2B)
23304  except:
23305  chb_TC2Entry.delete(0,END)
23306  chb_TC2Entry.insert(0, CHB_TC2.get())
23307  #
23308  try:
23309  Gain1B = float(chb_A1Entry.get())
23310  CHB_A1.set(Gain1B)
23311  except:
23312  chb_A1Entry.delete(0,END)
23313  chb_A1Entry.insert(0, CHB_A1.get())
23314  try:
23315  Gain2B = float(chb_A2Entry.get())
23316  CHB_A2.set(Gain2B)
23317  except:
23318  chb_A2Entry.delete(0,END)
23319  chb_A2Entry.insert(0, CHB_A2.get())
23320  # set ETS base comp
23321  #
23322  SetETSComp()
23323 #
23325  global Settingswindow, SettingsStatus
23326 
23327  SettingsStatus.set(0)
23328  SettingsUpdate()
23329  Settingswindow.destroy()
23330 #
23331 def onCanvasMouse_xy(event):
23332  global MouseX, MouseY, MouseWidget
23333 
23334  MouseWidget = event.widget
23335  MouseX, MouseY = event.x, event.y
23336 #
23337 def BSetFmin():
23338  global FminEntry, CHAfreq
23339 
23340  if CHAfreq > 0:
23341  String = '{0:.3f}'.format(CHAfreq/1000)
23342  FminEntry.delete(0,"end")
23343  FminEntry.insert(0,String)
23344 #
23345 def ReSetAGO():
23346  global CHAVGainEntry, CHAVOffsetEntry
23347 
23348  CHAVGainEntry.delete(0,"end")
23349  CHAVGainEntry.insert(0,1.0)
23350  CHAVOffsetEntry.delete(0,"end")
23351  CHAVOffsetEntry.insert(0,0.0)
23352 #
23353 def ReSetBGO():
23354  global CHBVGainEntry, CHBVOffsetEntry
23355 
23356  CHBVGainEntry.delete(0,"end")
23357  CHBVGainEntry.insert(0,1.0)
23358  CHBVOffsetEntry.delete(0,"end")
23359  CHBVOffsetEntry.insert(0,0.0)
23360 #
23362  global CHAIGainEntry, CHAIOffsetEntry
23363 
23364  CHAIGainEntry.delete(0,"end")
23365  CHAIGainEntry.insert(0,1.0)
23366  CHAIOffsetEntry.delete(0,"end")
23367  CHAIOffsetEntry.insert(0,0.0)
23368 #
23370  global CHBIGainEntry, CHBIOffsetEntry
23371 
23372  CHBIGainEntry.delete(0,"end")
23373  CHBIGainEntry.insert(0,1.0)
23374  CHBIOffsetEntry.delete(0,"end")
23375  CHBIOffsetEntry.insert(0,0.0)
23376 #
23378  global EnablePhaseAnalizer, EnableSpectrumAnalizer, EnableBodePlotter, EnableImpedanceAnalizer
23379  global EnableOhmMeter, OOTphckb, OOTBuildPhAScreen, OOTckb3, OOTBuildSpectrumScreen, OOTckb5, ckb1
23380  global OOTBuildBodeScreen, OOTckb4, OOTBuildIAScreen, OOTckb6, OOTBuildOhmScreen, OOTScreenStatus
23381  global OOTwindow, SWRev, RevDate, BorderSize, FrameRefief, OOTdismissclbutton, EnableDigIO
23382  global EnablePIODACMode, EnableMuxMode, EnableMinigenMode, EnablePmodDA1Mode, EnableDigPotMode, EnableGenericSerialMode
23383  global EnableAD5626SerialMode, EnableDigitalFilter, EnableCommandInterface, EnableMeasureScreen, EnableETSScreen
23384 
23385  if OOTScreenStatus.get() == 0:
23386  OOTScreenStatus.set(1)
23387  OOTwindow = Toplevel()
23388  OOTwindow.title("Instruments " + SWRev + RevDate)
23389  OOTwindow.resizable(FALSE,FALSE)
23390  OOTwindow.protocol("WM_DELETE_WINDOW", DestroyOOTwindow)
23391  frame1 = Frame(OOTwindow, borderwidth=BorderSize, relief=FrameRefief)
23392  frame1.grid(row=0, column=0, sticky=W)
23393  #
23394  nextrow = 1
23395  timebtn = Frame( frame1 )
23396  timebtn.grid(row=nextrow, column=0, sticky=W)
23397  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
23398  ckb1.pack(side=LEFT)
23399  timelab = Label(timebtn, text="Time Plot")
23400  timelab.pack(side=LEFT)
23401  nextrow = nextrow + 1
23402  if EnablePhaseAnalizer > 0:
23403  phasebtn = Frame( frame1 )
23404  phasebtn.grid(row=nextrow, column=0, sticky=W)
23405  OOTphckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
23406  OOTphckb.pack(side=LEFT)
23407  OOTBuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
23408  OOTBuildPhAScreen.pack(side=LEFT)
23409  nextrow = nextrow + 1
23410  #
23411  if EnableSpectrumAnalizer > 0:
23412  freqbtn = Frame( frame1 )
23413  freqbtn.grid(row=nextrow, column=0, sticky=W)
23414  OOTckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
23415  OOTckb3.pack(side=LEFT)
23416  OOTBuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
23417  OOTBuildSpectrumScreen.pack(side=LEFT)
23418  nextrow = nextrow + 1
23419  #
23420  if EnableBodePlotter > 0:
23421  bodebtn = Frame( frame1 )
23422  bodebtn.grid(row=nextrow, column=0, sticky=W)
23423  OOTckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
23424  OOTckb5.pack(side=LEFT)
23425  OOTBuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
23426  OOTBuildBodeScreen.pack(side=LEFT)
23427  nextrow = nextrow + 1
23428  #
23429  if EnableImpedanceAnalizer > 0:
23430  impdbtn = Frame( frame1 )
23431  impdbtn.grid(row=nextrow, column=0, sticky=W)
23432  OOTckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
23433  OOTckb4.pack(side=LEFT)
23434  OOTBuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
23435  OOTBuildIAScreen.pack(side=LEFT)
23436  nextrow = nextrow + 1
23437  #
23438  if EnableOhmMeter > 0:
23439  dcohmbtn = Frame( frame1 )
23440  dcohmbtn.grid(row=nextrow, column=0, sticky=W)
23441  OOTckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
23442  OOTckb6.pack(side=LEFT)
23443  OOTBuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
23444  OOTBuildOhmScreen.pack(side=LEFT)
23445  nextrow = nextrow + 1
23446 
23447  if EnableDigIO > 0:
23448  OOTBuildDigScreen = Button(frame1, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
23449  OOTBuildDigScreen.grid(row=nextrow, column=0, sticky=W)
23450  nextrow = nextrow + 1
23451  # Optional plugin tools
23452  if EnablePIODACMode > 0:
23453  OOTBuildDacScreen = Button(frame1, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
23454  OOTBuildDacScreen.grid(row=nextrow, column=0, sticky=W)
23455  nextrow = nextrow + 1
23456  if EnableMuxMode > 0:
23457  OOTBuildMuxScreen = Button(frame1, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
23458  OOTBuildMuxScreen.grid(row=nextrow, column=0, sticky=W)
23459  nextrow = nextrow + 1
23460  if EnableMinigenMode > 0:
23461  OOTBuildMinigenScreen = Button(frame1, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
23462  OOTBuildMinigenScreen.grid(row=nextrow, column=0, sticky=W)
23463  nextrow = nextrow + 1
23464  if EnablePmodDA1Mode > 0:
23465  OOTBuildDA1Screen = Button(frame1, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
23466  OOTBuildDA1Screen.grid(row=nextrow, column=0, sticky=W)
23467  nextrow = nextrow + 1
23468  if EnableDigPotMode >0:
23469  OOTBuildDigPotScreen = Button(frame1, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
23470  OOTBuildDigPotScreen.grid(row=nextrow, column=0, sticky=W)
23471  nextrow = nextrow + 1
23472  if EnableGenericSerialMode >0:
23473  OOTGenericSerialScreen = Button(frame1, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
23474  OOTGenericSerialScreen.grid(row=nextrow, column=0, sticky=W)
23475  nextrow = nextrow + 1
23476  if EnableAD5626SerialMode >0:
23477  OOTAD5626SerialScreen = Button(frame1, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
23478  OOTAD5626SerialScreen.grid(row=nextrow, column=0, sticky=W)
23479  nextrow = nextrow + 1
23480  if EnableDigitalFilter >0:
23481  OOTDigFiltScreen = Button(frame1, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
23482  OOTDigFiltScreen.grid(row=nextrow, column=0, sticky=W)
23483  nextrow = nextrow + 1
23484  if EnableCommandInterface > 0:
23485  OOTCommandLineScreen = Button(frame1, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
23486  OOTCommandLineScreen.grid(row=nextrow, column=0, sticky=W)
23487  nextrow = nextrow + 1
23488  if EnableMeasureScreen > 0:
23489  OOTMeasureScreen = Button(frame1, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
23490  OOTMeasureScreen.grid(row=nextrow, column=0, sticky=W)
23491  nextrow = nextrow + 1
23492  if EnableETSScreen > 0:
23493  OOTETSScreen = Button(frame1, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
23494  OOTETSScreen.grid(row=nextrow, column=0, sticky=W)
23495  nextrow = nextrow + 1
23496  #
23497  OOTdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOOTwindow)
23498  OOTdismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
23499 #
23501  global OOTwindow, OOTScreenStatus
23502 
23503  OOTScreenStatus.set(0)
23504  OOTwindow.destroy()
23505 #
23506 #
23507 # ================ Make main Screen ==========================
23508 TgInput = IntVar(0) # Trigger Input variable
23509 SingleShot = IntVar(0) # variable for single shot triger
23510 ManualTrigger = IntVar(0) # variable for Manual trigger
23511 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
23512 ShowC1_V = IntVar(0) # curves to display variables
23513 TgEdge = IntVar(0) # Trigger edge variable
23514 # Show channels variables
23515 ShowC1_V = IntVar(0) # curves to display variables
23516 ShowC1_I = IntVar(0)
23517 ShowC2_V = IntVar(0)
23518 ShowC2_I = IntVar(0)
23519 ShowAV_I = IntVar(0)
23520 ShowBV_I = IntVar(0)
23521 ShowRA_V = IntVar(0)
23522 ShowRA_I = IntVar(0)
23523 ShowRB_V = IntVar(0)
23524 ShowRB_I = IntVar(0)
23525 ShowMath = IntVar(0)
23526 ShowPB_A = IntVar(0)
23527 ShowPB_B = IntVar(0)
23528 ShowPB_C = IntVar(0)
23529 ShowPB_D = IntVar(0)
23530 # Bode and SA variables
23531 ShowC1_VdB = IntVar(0) # curves to display variables
23532 ShowC1_P = IntVar(0)
23533 ShowC2_VdB = IntVar(0)
23534 ShowC2_P = IntVar(0)
23535 ShowMarker = IntVar(0)
23536 ShowRA_VdB = IntVar(0)
23537 ShowRA_P = IntVar(0)
23538 ShowRB_VdB = IntVar(0)
23539 ShowRB_P = IntVar(0)
23540 ShowMathSA = IntVar(0)
23541 ShowRMath = IntVar(0)
23542 ShowAWGASA = IntVar(0)
23543 ShowAWGBSA = IntVar(0)
23544 HScaleBP = IntVar(0)
23545 HScaleBP.set(1)
23546 #
23547 Show_MathX = IntVar(0)
23548 Show_MathY = IntVar(0)
23549 AutoCenterA = IntVar(0)
23550 AutoCenterB = IntVar(0)
23551 SmoothCurves = IntVar(0)
23552 ZOHold = IntVar(0)
23553 TRACEmodeTime = IntVar(0)
23554 TRACEmodeTime.set(0)
23555 DecimateOption = IntVar(0)
23556 MathTrace = IntVar(0)
23557 # AWG variables
23558 AWGAMode = IntVar(0) # AWG A mode variable
23559 AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
23560 AWGATerm = IntVar(0) # AWG A termination variable
23561 AWGAShape = IntVar(0) # AWG A Wave shape variable
23562 AWGAPhaseDelay = IntVar(0) #
23563 AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
23564 AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
23565 AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
23566 AWGBMode = IntVar(0) # AWG B mode variable
23567 AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
23568 AWGBTerm = IntVar(0) # AWG B termination variable
23569 AWGBShape = IntVar(0) # AWG B Wave shape variable
23570 AWGBPhaseDelay = IntVar(0) #
23571 AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
23572 AWGAMode.set(2)
23573 AWGBMode.set(2)
23574 AWGSync = IntVar(0) # Sync start both AWG channels
23575 AWGSync.set(1)
23576 BisCompA = IntVar(0) # Make Channel B comp of channel A
23577 BisCompA.set(0)
23578 # define vertical measurment variables
23579 MeasDCV1 = IntVar(0)
23580 MeasMinV1 = IntVar(0)
23581 MeasMaxV1 = IntVar(0)
23582 MeasMidV1 = IntVar(0)
23583 MeasPPV1 = IntVar(0)
23584 MeasRMSV1 = IntVar(0)
23585 MeasRMSVA_B = IntVar(0)
23586 MeasDCI1 = IntVar(0)
23587 MeasMinI1 = IntVar(0)
23588 MeasMaxI1 = IntVar(0)
23589 MeasMidI1 = IntVar(0)
23590 MeasPPI1 = IntVar(0)
23591 MeasRMSI1 = IntVar(0)
23592 MeasDiffAB = IntVar(0)
23593 MeasDCV2 = IntVar(0)
23594 MeasMinV2 = IntVar(0)
23595 MeasMaxV2 = IntVar(0)
23596 MeasMidV2 = IntVar(0)
23597 MeasPPV2 = IntVar(0)
23598 MeasRMSV2 = IntVar(0)
23599 MeasDCI2 = IntVar(0)
23600 MeasMinI2 = IntVar(0)
23601 MeasMaxI2 = IntVar(0)
23602 MeasMidI2 = IntVar(0)
23603 MeasPPI2 = IntVar(0)
23604 MeasRMSI2 = IntVar(0)
23605 MeasDiffBA = IntVar(0)
23606 MeasUserA = IntVar(0)
23607 MeasAHW = IntVar(0)
23608 MeasALW = IntVar(0)
23609 MeasADCy = IntVar(0)
23610 MeasAPER = IntVar(0)
23611 MeasAFREQ = IntVar(0)
23612 MeasBHW = IntVar(0)
23613 MeasBLW = IntVar(0)
23614 MeasBDCy = IntVar(0)
23615 MeasBPER = IntVar(0)
23616 MeasBFREQ = IntVar(0)
23617 MeasPhase = IntVar(0)
23618 MeasTopV1 = IntVar(0)
23619 MeasBaseV1 = IntVar(0)
23620 MeasTopV2 = IntVar(0)
23621 MeasBaseV2 = IntVar(0)
23622 MeasUserB = IntVar(0)
23623 MeasDelay = IntVar(0)
23624 TimeDisp = IntVar(0)
23625 TimeDisp.set(1)
23626 XYDisp = IntVar(0)
23627 FreqDisp = IntVar(0)
23628 PhADisp = IntVar(0)
23629 BodeDisp = IntVar(0)
23630 IADisp = IntVar(0)
23631 OhmDisp = IntVar(0)
23632 OOTScreenStatus = IntVar(0)
23633 OOTScreenStatus.set(0)
23634 PhAScreenStatus = IntVar(0)
23635 PhAScreenStatus.set(0)
23636 AppendPhAData = IntVar(0)
23637 AppendPhAData.set(0)
23638 PhAPlotMode = IntVar(0)
23639 PhADatafilename = "PhaseData.csv"
23640 BodeScreenStatus = IntVar(0)
23641 BodeScreenStatus.set(0)
23642 DigScreenStatus = IntVar(0)
23643 DigScreenStatus.set(0)
23644 DacScreenStatus = IntVar(0)
23645 DacScreenStatus.set(0)
23646 MuxScreenStatus = IntVar(0)
23647 MuxScreenStatus.set(0)
23648 MuxEnb = IntVar(0)
23649 MuxSync = IntVar(0)
23650 DualMuxMode = IntVar(0)
23651 ChopMuxMode = IntVar(0)
23652 ChopTrig = IntVar(0)
23653 MinigenScreenStatus = IntVar(0)
23654 MinigenScreenStatus.set(0)
23655 DA1ScreenStatus = IntVar(0)
23656 DA1ScreenStatus.set(0)
23657 DigPotScreenStatus = IntVar(0)
23658 DigPotScreenStatus.set(0)
23659 GenericSerialStatus = IntVar(0)
23660 GenericSerialStatus.set(0)
23661 AD5626SerialStatus = IntVar(0)
23662 AD5626SerialStatus.set(0)
23663 DigFiltStatus = IntVar(0)
23664 DigFiltStatus.set(0)
23665 CommandStatus = IntVar(0)
23666 CommandStatus.set(0)
23667 MeasureStatus = IntVar(0)
23668 MeasureStatus.set(0)
23669 MarkerScale = IntVar(0)
23670 MarkerScale.set(1)
23671 SettingsStatus = IntVar(0)
23672 CHA_RC_HP = IntVar(0)
23673 CHB_RC_HP = IntVar(0)
23674 CHAI_RC_HP = IntVar(0)
23675 CHBI_RC_HP = IntVar(0)
23676 HScale = IntVar(0)
23677 SAVScale = IntVar(0)
23678 SAVPSD = IntVar(0)
23679 SAvertmax = 1.0
23680 SAvertmin = 1.0E-6
23681 #
23682 if GUITheme == "Light": # Can be Light or Dark or Blue or LtBlue
23683  FrameBG = "#d7d7d7"
23684  ButtonText = "#000000"
23685 elif GUITheme == "Dark":
23686  FrameBG = "#484848"
23687  ButtonText = "#ffffff"
23688 elif GUITheme == "Blue":
23689  FrameBG = "#242468"
23690  ButtonText = "#d0d0ff"
23691 elif GUITheme == "LtBlue":
23692  FrameBG = "#c0e8ff"
23693  ButtonText = "#000040"
23694 EntryText = "#000000"
23695 BoxColor = "#0000ff" # 100% blue
23696 root.style.configure("TFrame", background=FrameBG, borderwidth=BorderSize)
23697 root.style.configure("TLabelframe", background=FrameBG)
23698 root.style.configure("TLabel", foreground=ButtonText, background=FrameBG, relief=LabRelief)
23699 root.style.configure("TEntry", foreground=EntryText, background=FrameBG, relief=ButRelief) #cursor='sb_v_double_arrow'
23700 root.style.configure("TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23701 root.style.configure("TRadiobutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23702 root.style.configure("TButton", foreground=ButtonText, background=FrameBG, highlightcolor=FrameBG, relief=ButRelief)
23703 # define custom buttons and labels
23704 root.style.configure("TSpinbox", arrowsize=SBoxarrow) # 11 only changes things in Python 3
23705 root.style.configure("W3.TButton", width=3, relief=ButRelief)
23706 root.style.configure("W4.TButton", width=4, relief=ButRelief)
23707 root.style.configure("W5.TButton", width=5, relief=ButRelief)
23708 root.style.configure("W6.TButton", width=6, relief=ButRelief)
23709 root.style.configure("W7.TButton", width=7, relief=ButRelief)
23710 root.style.configure("W8.TButton", width=8, relief=ButRelief)
23711 root.style.configure("W9.TButton", width=9, relief=ButRelief)
23712 root.style.configure("W10.TButton", width=10, relief=ButRelief)
23713 root.style.configure("W11.TButton", width=11, relief=ButRelief)
23714 root.style.configure("W16.TButton", width=16, relief=ButRelief)
23715 root.style.configure("W17.TButton", width=17, relief=ButRelief)
23716 root.style.configure("Stop.TButton", background=ButtonRed, foreground="#000000", width=4, relief=ButRelief)
23717 root.style.configure("Run.TButton", background=ButtonGreen, foreground="#000000", width=4, relief=ButRelief)
23718 root.style.configure("Pwr.TButton", background=ButtonGreen, foreground="#000000", width=8, relief=ButRelief)
23719 root.style.configure("PwrOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23720 root.style.configure("Roll.TButton", background=ButtonGreen, foreground="#000000", width=7, relief=ButRelief)
23721 root.style.configure("RollOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23722 root.style.configure("RConn.TButton", background=ButtonRed, foreground="#000000", width=5, relief=ButRelief)
23723 root.style.configure("GConn.TButton", background=ButtonGreen, foreground="#000000", width=5, relief=ButRelief)
23724 root.style.configure("Rtrace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=RAISED)
23725 root.style.configure("Strace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=SUNKEN)
23726 root.style.configure("Ctrace1.TButton", background=COLORtrace1, foreground="#000000", relief=ButRelief)
23727 root.style.configure("Rtrace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=RAISED)
23728 root.style.configure("Strace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=SUNKEN)
23729 root.style.configure("Ctrace2.TButton", background=COLORtrace2, foreground="#000000", relief=ButRelief)
23730 root.style.configure("Rtrace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=RAISED)
23731 root.style.configure("Strace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=SUNKEN)
23732 root.style.configure("Ctrace3.TButton", background=COLORtrace3, foreground="#000000", relief=ButRelief)
23733 root.style.configure("Rtrace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=RAISED)
23734 root.style.configure("Strace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=SUNKEN)
23735 root.style.configure("Ctrace4.TButton", background=COLORtrace4, foreground="#000000", relief=ButRelief)
23736 root.style.configure("Rtrace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=RAISED)
23737 root.style.configure("Strace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=SUNKEN)
23738 root.style.configure("Rtrace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=RAISED)
23739 root.style.configure("Strace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=SUNKEN)
23740 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
23741 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
23742 #
23743 root.style.configure("A10T5.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR5, font=('Arial', 10, 'bold'))
23744 root.style.configure("A10T5.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23745 root.style.configure("A10T6.TLabelframe.Label", background=FrameBG, foreground=COLORtrace6, font=('Arial', 10, 'bold'))
23746 root.style.configure("A10T6.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23747 root.style.configure("A10T7.TLabelframe.Label", background=FrameBG, foreground=COLORtrace7, font=('Arial', 10, 'bold'))
23748 root.style.configure("A10T7.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23749 #
23750 root.style.configure("A10R1.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
23751 root.style.configure("A10R1.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23752 root.style.configure("A10R2.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
23753 root.style.configure("A10R2.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23754 root.style.configure("A10.TLabelframe.Label", background=FrameBG, font=('Arial', 10, 'bold'))
23755 root.style.configure("A10.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23756 root.style.configure("A10B.TLabel", foreground=ButtonText, font="Arial 10 bold") # Black text
23757 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
23758 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
23759 root.style.configure("A12B.TLabel", foreground=ButtonText, font="Arial 12 bold") # Black text
23760 root.style.configure("A16B.TLabel", foreground=ButtonText, font="Arial 16 bold") # Black text
23761 root.style.configure("Stop.TRadiobutton", background=ButtonRed, indicatorcolor=FrameBG)
23762 root.style.configure("Run.TRadiobutton", background=ButtonGreen, indicatorcolor=FrameBG)
23763 root.style.configure("Disab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonRed)
23764 root.style.configure("Enab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonGreen)
23765 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1, foreground="#000000", indicatorcolor="#ffffff")
23766 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2, foreground="#000000", indicatorcolor="#ffffff")
23767 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3, foreground="#000000", indicatorcolor="#ffffff")
23768 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4, foreground="#000000", indicatorcolor="#ffffff")
23769 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6, foreground="#000000", indicatorcolor="#ffffff")
23770 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7, foreground="#000000", indicatorcolor="#ffffff")
23771 root.style.configure("WPhase.TRadiobutton", width=5, foreground="#000000", background="white", indicatorcolor=("red", "green"))
23772 root.style.configure("GPhase.TRadiobutton", width=5, foreground="#000000", background="gray", indicatorcolor=("red", "green"))
23773 # Create frames
23774 frame2r = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23775 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
23776 
23777 frame1 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23778 frame1.pack(side=TOP, fill=BOTH, expand=NO)
23779 
23780 frame2 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23781 frame2.pack(side=TOP, fill=BOTH, expand=YES)
23782 
23783 frame3 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23784 frame3.pack(side=TOP, fill=BOTH, expand=NO)
23785 # create a pulldown menu
23786 # Trigger signals
23787 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
23788 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
23789 Triggermenu["menu"] = Triggermenu.menu
23790 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
23791 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
23792 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
23793 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
23794 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
23795 Triggermenu.menu.add_radiobutton(label='CA-V or CB-V', variable=TgInput, value=5)
23796 # Triggermenu.menu.add_radiobutton(label='Alternate A/B', variable=TgInput, value=6)
23797 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
23798 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
23799 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
23800 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
23801 Triggermenu.pack(side=LEFT)
23802 #
23803 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
23804 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
23805 Edgemenu["menu"] = Edgemenu.menu
23806 Edgemenu.menu.add_radiobutton(label='Rising (+)', variable=TgEdge, value=0)
23807 Edgemenu.menu.add_radiobutton(label='Falling (-)', variable=TgEdge, value=1)
23808 Edgemenu.pack(side=LEFT)
23809 #
23810 tlab = Label(frame1, text="Trig Level")
23811 tlab.pack(side=LEFT)
23812 TRIGGERentry = Entry(frame1, width=5, cursor='double_arrow')
23813 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
23814 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
23815 TRIGGERentry.bind("<Button-5>", onTextScroll)
23816 TRIGGERentry.bind("<Return>", BTriglevel)
23817 TRIGGERentry.bind('<Key>', onTextKey)
23818 TRIGGERentry.pack(side=LEFT)
23819 TRIGGERentry.delete(0,"end")
23820 TRIGGERentry.insert(0,0.0)
23821 #
23822 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
23823 tgb.pack(side=LEFT)
23824 #
23825 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
23826 hldlab.pack(side=LEFT)
23827 HoldOffentry = Entry(frame1, width=4, cursor='double_arrow')
23828 HoldOffentry.bind('<MouseWheel>', onTextScroll)
23829 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
23830 HoldOffentry.bind("<Button-5>", onTextScroll)
23831 HoldOffentry.bind("<Return>", BHoldOff)
23832 HoldOffentry.bind('<Key>', onTextKey)
23833 HoldOffentry.pack(side=LEFT)
23834 HoldOffentry.delete(0,"end")
23835 HoldOffentry.insert(0,0.0)
23836 #
23837 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
23838 hozlab.pack(side=LEFT)
23839 HozPossentry = Entry(frame1, width=4, cursor='double_arrow')
23840 HozPossentry.bind('<MouseWheel>', onTextScroll)
23841 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
23842 HozPossentry.bind("<Button-5>", onTextScroll)
23843 HozPossentry.bind("<Return>", BHozPoss)
23844 HozPossentry.bind('<Key>', onTextKey)
23845 HozPossentry.pack(side=LEFT)
23846 HozPossentry.delete(0,"end")
23847 HozPossentry.insert(0,0.0)
23848 #
23849 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
23850 bexit.pack(side=RIGHT)
23851 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
23852 bstop.pack(side=RIGHT)
23853 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
23854 brun.pack(side=RIGHT)
23855 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
23856 PwrBt.pack(side=RIGHT)
23857 # Curves Menu
23858 if EnableScopeOnly == 0:
23859  Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
23860 else:
23861  Showmenu = Menubutton(frame1, text="Traces", style="W7.TButton")
23862 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
23863 Showmenu["menu"] = Showmenu.menu
23864 Showmenu.menu.add_command(label="-Show Traces-", foreground="blue", command=donothing)
23865 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
23866 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
23867 Showmenu.menu.add_checkbutton(label='CA-V (1)', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
23868 Showmenu.menu.add_checkbutton(label='CA-I (3)', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
23869 Showmenu.menu.add_checkbutton(label='CB-V (2)', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
23870 Showmenu.menu.add_checkbutton(label='CB-I (4)', background=COLORtrace4,variable=ShowC2_I, command=TraceSelectADC_Mux)
23871 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
23872 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
23873 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
23874 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
23875 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
23876 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
23877 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
23878 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
23879 if EnableHSsampling > 0:
23880  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
23881  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
23882 Showmenu.menu.add_separator()
23883 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
23884 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
23885 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
23886 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
23887 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
23888 Showmenu.menu.add_separator()
23889 Showmenu.menu.add_checkbutton(label='T Cursor (t)', variable=ShowTCur, command=UpdateTimeTrace)
23890 Showmenu.menu.add_checkbutton(label='V Cursor (v)', variable=ShowVCur, command=UpdateTimeTrace)
23891 Showmenu.pack(side=RIGHT)
23892 #
23893 if ShowBallonHelp > 0:
23894  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
23895  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
23896  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
23897  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
23898  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
23899  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
23900  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
23901  brun_tip = CreateToolTip(brun, 'Start acquiring data')
23902  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
23903  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
23904 
23905 # Sampling controls Widgets
23906 if EnableHSsampling > 0:
23907  fminlab2 = Label(frame1, text="KHz")
23908  fminlab2.pack(side=RIGHT)
23909  FminEntry = Entry(frame1, width=6, cursor='double_arrow')
23910  FminEntry.bind('<MouseWheel>', onFminScroll)
23911  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
23912  FminEntry.bind("<Button-5>", onFminScroll)
23913  FminEntry.bind("<Return>", SetAD9833)
23914  FminEntry.pack(side=RIGHT)
23915  FminEntry.delete(0,"end")
23916  FminEntry.insert(0,25)
23917  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
23918  fminlab.pack(side=RIGHT)
23919  #
23920  HtMulEntry = Entry(frame1, width=4, cursor='double_arrow')
23921  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
23922  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
23923  HtMulEntry.bind("<Button-5>", onMulXScroll)
23924  HtMulEntry.bind("<Return>", SetAD9833)
23925  HtMulEntry.pack(side=RIGHT)
23926  HtMulEntry.delete(0,"end")
23927  HtMulEntry.insert(0,1)
23928  mulxlab = Label( frame1, text = "Mul X")
23929  mulxlab.pack(side=RIGHT)
23930 else:
23931  RollBt = Button(frame1, text="Roll-Off", style="RollOff.TButton", command=BRoll)
23932  RollBt.pack(side=RIGHT)
23933 #
23934 # Time per Div
23935 TMsb = Spinbox(frame1, width=5, values= TMpdiv, cursor='double_arrow', command=BTime)
23936 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
23937 TMsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
23938 TMsb.bind("<Button-5>", onSpinBoxScroll)
23939 TMsb.pack(side=RIGHT)
23940 TMsb.delete(0,"end")
23941 TMsb.insert(0,0.5)
23942 TMlab = Label(frame1, text="Time mS/Div")
23943 TMlab.pack(side=RIGHT)
23944 #
23945 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
23946 # add mouse left and right button click to canvas
23947 ca.bind('<Configure>', CAresize)
23948 ca.bind('<1>', onCanvasClickLeft)
23949 ca.bind('<3>', onCanvasClickRight)
23950 ca.bind("<Motion>",onCanvasMouse_xy)
23951 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
23952 ca.bind("<Down>", onCanvasDownArrow)
23953 ca.bind("<Left>", onCanvasLeftArrow)
23954 ca.bind("<Right>", onCanvasRightArrow)
23955 ca.bind("<space>", onCanvasSpaceBar)
23956 ca.bind("1", onCanvasOne)
23957 ca.bind("2", onCanvasTwo)
23958 ca.bind("3", onCanvasThree)
23959 ca.bind("4", onCanvasFour)
23960 ca.bind("5", onCanvasFive)
23961 ca.bind("6", onCanvasSix)
23962 ca.bind("7", onCanvasSeven)
23963 ca.bind("8", onCanvasEight)
23964 ca.bind("9", onCanvasNine)
23965 ca.bind("0", onCanvasZero)
23966 ca.bind("a", onCanvasAverage)
23967 ca.bind("t", onCanvasShowTcur)
23968 ca.bind("v", onCanvasShowVcur)
23969 ca.bind("s", onCanvasSnap)
23970 ca.bind("+", onCanvasTrising)
23971 ca.bind("-", onCanvasTfalling)
23972 ca.bind('<MouseWheel>', onCanvasClickScroll)
23973 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
23974 ca.bind("<Button-5>", onCanvasClickScroll)
23975 ca.pack(side=TOP, fill=BOTH, expand=YES)
23976 MouseWidget = ca
23977 # right side menu buttons
23978 dropmenu = Frame( frame2r )
23979 dropmenu.pack(side=TOP)
23980 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
23981 bcon.pack(side=LEFT, anchor=W)
23982 # File menu
23983 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
23984 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
23985 Filemenu["menu"] = Filemenu.menu
23986 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
23987 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
23988 Filemenu.menu.add_command(label="Run Script", command=RunScript)
23989 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
23990 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
23991 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
23992 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
23993 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
23994 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
23995 Filemenu.menu.add_command(label="Help", command=BHelp)
23996 Filemenu.menu.add_command(label="About", command=BAbout)
23997 Filemenu.pack(side=LEFT, anchor=W)
23998 # Options Menu
23999 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
24000 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
24001 Optionmenu["menu"] = Optionmenu.menu
24002 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
24003 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
24004 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
24005 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
24006 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
24007 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
24008 Optionmenu.menu.add_checkbutton(label='Trace Avg (a)', variable=TRACEmodeTime)
24009 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
24010 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
24011 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
24012 Optionmenu.menu.add_command(label="SnapShot (s)", command=BSnapShot)
24013 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
24014 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
24015 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
24016 if EnableScopeOnly != 0:
24017  Optionmenu.menu.add_command(label="Open Instruments", command=OpenOtherTools)
24018 if AllowFlashFirmware == 1:
24019  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
24020  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
24021 Optionmenu.pack(side=LEFT, anchor=W)
24022 #
24023 dropmenu2 = Frame( frame2r )
24024 dropmenu2.pack(side=TOP)
24025 # Open Math trace menu
24026 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
24027 mathbt.pack(side=RIGHT, anchor=W)
24028 # Measurments menu
24029 measlab = Label(dropmenu2, text="Meas")
24030 measlab.pack(side=LEFT, anchor=W)
24031 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
24032 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
24033 MeasmenuA["menu"] = MeasmenuA.menu
24034 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
24035 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
24036 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
24037 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
24038 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
24039 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
24040 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
24041 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
24042 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
24043 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
24044 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
24045 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
24046 #MeasmenuA.menu.add_separator()
24047 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
24048 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
24049 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
24050 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
24051 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
24052 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
24053 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
24054 #MeasmenuA.menu.add_separator()
24055 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
24056 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
24057 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
24058 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
24059 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
24060 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
24061 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
24062 #
24063 MeasmenuA.pack(side=LEFT)
24064 #
24065 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
24066 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
24067 MeasmenuB["menu"] = MeasmenuB.menu
24068 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
24069 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
24070 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
24071 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
24072 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
24073 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
24074 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
24075 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
24076 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
24077 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
24078 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
24079 #MeasmenuB.menu.add_separator()
24080 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
24081 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
24082 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
24083 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
24084 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
24085 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
24086 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
24087 #MeasmenuB.menu.add_separator()
24088 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
24089 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
24090 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
24091 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
24092 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
24093 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
24094 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
24095 MeasmenuB.pack(side=LEFT)
24096 if ShowBallonHelp > 0:
24097  math_tip = CreateToolTip(mathbt, 'Open Math window')
24098  options_tip = CreateToolTip(Optionmenu, 'Select Optional Settings')
24099  file_tip = CreateToolTip(Filemenu, 'Select File operations')
24100 #
24101 DigScreenStatus = IntVar(0)
24102 DigScreenStatus.set(0)
24103 #
24104 if EnableScopeOnly == 0:
24105  BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
24106  BuildAWGScreen.pack(side=TOP)
24107  # Mode selector
24108  timebtn = Frame( frame2r )
24109  timebtn.pack(side=TOP)
24110  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24111  ckb1.pack(side=LEFT)
24112  timelab = Label(timebtn, text="Time Plot")
24113  timelab.pack(side=LEFT)
24114  if EnableXYPlotter > 0:
24115  xybtn = Frame( frame2r )
24116  xybtn.pack(side=TOP)
24117  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24118  ckb2.pack(side=LEFT)
24119  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24120  BuildXYScreen.pack(side=TOP)
24121  #
24122  if EnablePhaseAnalizer > 0:
24123  phasebtn = Frame( frame2r )
24124  phasebtn.pack(side=TOP)
24125  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24126  phckb.pack(side=LEFT)
24127  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24128  BuildPhAScreen.pack(side=LEFT)
24129  #
24130  if EnableSpectrumAnalizer > 0:
24131  freqbtn = Frame( frame2r )
24132  freqbtn.pack(side=TOP)
24133  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24134  ckb3.pack(side=LEFT)
24135  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24136  BuildSpectrumScreen.pack(side=LEFT)
24137  #
24138  if EnableBodePlotter > 0:
24139  bodebtn = Frame( frame2r )
24140  bodebtn.pack(side=TOP)
24141  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24142  ckb5.pack(side=LEFT)
24143  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24144  BuildBodeScreen.pack(side=LEFT)
24145  #
24146  if EnableImpedanceAnalizer > 0:
24147  impdbtn = Frame( frame2r )
24148  impdbtn.pack(side=TOP)
24149  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24150  ckb4.pack(side=LEFT)
24151  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24152  BuildIAScreen.pack(side=LEFT)
24153  #
24154  if EnableOhmMeter > 0:
24155  dcohmbtn = Frame( frame2r )
24156  dcohmbtn.pack(side=TOP)
24157  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24158  ckb6.pack(side=LEFT)
24159  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24160  BuildOhmScreen.pack(side=LEFT)
24161  #
24162  if ShowTraceControls > 0:
24163  Labelfonttext = "Arial " + str(FontSize) + " bold"
24164  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24165  tracelab.pack(side=TOP)
24166  trctrla = Frame( frame2r )
24167  trctrla.pack(side=TOP)
24168  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24169  ckbt1.pack(side=LEFT,fill=X)
24170  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24171  ckbt2.pack(side=LEFT,fill=X)
24172  trctrlb = Frame( frame2r )
24173  trctrlb.pack(side=TOP)
24174  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24175  ckbt3.pack(side=LEFT,fill=X)
24176  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24177  ckbt4.pack(side=LEFT,fill=X)
24178 
24179  if ShowBallonHelp > 0:
24180  try:
24181  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
24182  except:
24183  donothing()
24184  try:
24185  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
24186  except:
24187  donothing()
24188  try:
24189  BuildPhAScreen_tip = CreateToolTip(BuildPhAScreen, 'Open Phase Analyzer window')
24190  except:
24191  donothing()
24192  try:
24193  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open Spectrum Analyzer window')
24194  except:
24195  donothing()
24196  try:
24197  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
24198  except:
24199  donothing()
24200  try:
24201  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance Analyzer window')
24202  except:
24203  donothing()
24204  try:
24205  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
24206  except:
24207  donothing()
24208  # Digital Input / Output Option screens
24209  if EnableDigIO > 0:
24210  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
24211  BuildDigScreen.pack(side=TOP)
24212  # Optional plugin tools
24213  if EnablePIODACMode > 0:
24214  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
24215  BuildDacScreen.pack(side=TOP)
24216  if EnableMuxMode > 0:
24217  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
24218  BuildMuxScreen.pack(side=TOP)
24219  if EnableMinigenMode > 0:
24220  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
24221  BuildMinigenScreen.pack(side=TOP)
24222  if EnablePmodDA1Mode > 0:
24223  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
24224  BuildDA1Screen.pack(side=TOP)
24225  if EnableDigPotMode >0:
24226  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
24227  BuildDigPotScreen.pack(side=TOP)
24228  if EnableGenericSerialMode >0:
24229  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
24230  GenericSerialScreen.pack(side=TOP)
24231  if EnableAD5626SerialMode >0:
24232  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
24233  AD5626SerialScreen.pack(side=TOP)
24234  if EnableDigitalFilter >0:
24235  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
24236  DigFiltScreen.pack(side=TOP)
24237  if EnableCommandInterface > 0:
24238  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
24239  CommandLineScreen.pack(side=TOP)
24240  if EnableMeasureScreen > 0:
24241  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
24242  MeasureScreen.pack(side=TOP)
24243  if EnableETSScreen > 0:
24244  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
24245  ETSScreen.pack(side=TOP)
24246 else:
24247 # Mode selector
24248  if EnableXYPlotter > 0:
24249  xybtn = Frame( frame2r )
24250  xybtn.pack(side=TOP)
24251  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24252  ckb2.pack(side=LEFT)
24253  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24254  BuildXYScreen.pack(side=TOP)
24255  #
24256  if ShowTraceControls > 0:
24257  Labelfonttext = "Arial " + str(FontSize) + " bold"
24258  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24259  tracelab.pack(side=TOP)
24260  trctrla = Frame( frame2r )
24261  trctrla.pack(side=TOP)
24262  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24263  ckbt1.pack(side=LEFT,fill=X)
24264  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24265  ckbt2.pack(side=LEFT,fill=X)
24266  trctrlb = Frame( frame2r )
24267  trctrlb.pack(side=TOP)
24268  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24269  ckbt3.pack(side=LEFT,fill=X)
24270  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24271  ckbt4.pack(side=LEFT,fill=X)
24272  #
24273  awg1eb = Frame( frame2r )
24274  awg1eb.pack(side=TOP)
24275  ModeAMenu = Menubutton(awg1eb, text="Mode", width=5, style="Ctrace1.TButton")#, style="W5.TButton")
24276  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
24277  ModeAMenu["menu"] = ModeAMenu.menu
24278  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24279  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
24280  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
24281  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
24282  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
24283  ModeAMenu.menu.add_separator()
24284  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24285  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
24286  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
24287  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
24288  ModeAMenu.pack(side=LEFT, anchor=W)
24289  ShapeAMenu = Menubutton(awg1eb, text="Shape", width=6, style="Ctrace1.TButton")#, style="W6.TButton")
24290  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
24291  ShapeAMenu["menu"] = ShapeAMenu.menu
24292  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24293  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
24294  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
24295  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
24296  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
24297  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
24298  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
24299  if AWGShowAdvanced.get() > 0:
24300  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24301  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
24302  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
24303  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
24304  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
24305  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
24306  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
24307  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
24308  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
24309  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
24310  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
24311  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
24312  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
24313  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
24314  else:
24315  ShapeAMenu.menu.add_separator()
24316  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
24317  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
24318  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
24319  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
24320  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
24321  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
24322  ShapeAMenu.pack(side=LEFT, anchor=W)
24323  #
24324  awg1model = Frame( frame2r )
24325  awg1model.pack(side=TOP,fill=X) #)
24326  AWGAModeLabel = Label(awg1model, text="AWG A Mode", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24327  AWGAModeLabel.pack(side=LEFT, fill=X)
24328  AWGAShapeLabel = Label(awg1model, text="AWG A Shape", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24329  AWGAShapeLabel.pack(side=LEFT, fill=X)
24330  #
24331  awg1ampl = Frame( frame2r )
24332  awg1ampl.pack(side=TOP,fill=X) #)
24333  amp1lab = Label(awg1ampl) #
24334  amp1lab.grid(row=0,column=0,sticky=E+S+N+W)
24335  off1lab = Label(awg1ampl) #
24336  off1lab.grid(row=0,column=1,sticky=E+S+N+W)
24337  freq1lab = Label(awg1ampl, text="Freq")
24338  freq1lab.grid(row=0,column=2,sticky=E+S+N+W)
24339  #
24340  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24341  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
24342  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
24343  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24344  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
24345  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
24346  AWGAAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24347  AWGAAmplEntry.delete(0,"end")
24348  AWGAAmplEntry.insert(0,0.0)
24349  #
24350  AWGAOffsetEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24351  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
24352  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
24353  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24354  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
24355  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
24356  AWGAOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24357  AWGAOffsetEntry.delete(0,"end")
24358  AWGAOffsetEntry.insert(0,0.0)
24359 
24360  if AWG_Amp_Mode.get() == 0:
24361  amp1lab.config(text = "Min" ) # change displayed value
24362  off1lab.config(text = "Max" ) # change displayed value
24363  else:
24364  amp1lab.config(text = "Amp" )
24365  off1lab.config(text = "Off" )
24366  # AWG Frequency sub frame
24367  AWGAFreqEntry = Entry(awg1ampl, width=7, cursor='double_arrow')
24368  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
24369  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
24370  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24371  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
24372  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
24373  AWGAFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24374  AWGAFreqEntry.delete(0,"end")
24375  AWGAFreqEntry.insert(0,100.0)
24376  # AWG Phase or delay select sub frame
24377  # AWG Phase entry sub frame
24378  awg1phase = Frame( frame2r )
24379  awg1phase.pack(side=TOP)
24380  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
24381  awgaph.pack(side=LEFT, anchor=W)
24382  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
24383  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
24384  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
24385  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24386  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
24387  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
24388  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
24389  AWGAPhaseEntry.delete(0,"end")
24390  AWGAPhaseEntry.insert(0,0)
24391  phasealab = Label(awg1phase, text="Deg")
24392  phasealab.pack(side=LEFT, anchor=W)
24393  # AWG duty cycle frame
24394  awg1dc = Frame( frame2r )
24395  awg1dc.pack(side=TOP)
24396  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
24397  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24398  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
24399  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24400  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
24401  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
24402  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
24403  AWGADutyCycleEntry.delete(0,"end")
24404  AWGADutyCycleEntry.insert(0,50)
24405  duty1lab = Label(awg1dc, text="%")
24406  duty1lab.pack(side=LEFT, anchor=W)
24407 
24420  awg2eb = Frame( frame2r )
24421  awg2eb.pack(side=TOP)
24422  ModeBMenu = Menubutton(awg2eb, text="Mode", width=5, style="Ctrace2.TButton")# , style="W5.TButton")
24423  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
24424  ModeBMenu["menu"] = ModeBMenu.menu
24425  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24426  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
24427  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
24428  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
24429  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
24430  ModeBMenu.menu.add_separator()
24431  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24432  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
24433  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
24434  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
24435  ModeBMenu.pack(side=LEFT, anchor=W)
24436  ShapeBMenu = Menubutton(awg2eb, text="Shape", width=6, style="Ctrace2.TButton")#, style="W6.TButton")
24437  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
24438  ShapeBMenu["menu"] = ShapeBMenu.menu
24439  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24440  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
24441  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
24442  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
24443  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
24444  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
24445  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
24446  if AWGShowAdvanced.get() > 0:
24447  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24448  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
24449  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
24450  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
24451  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
24452  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
24453  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
24454  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
24455  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
24456  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
24457  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
24458  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
24459  else:
24460  ShapeBMenu.menu.add_separator()
24461  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
24462  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
24463  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
24464  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
24465  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
24466  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
24467  ShapeBMenu.pack(side=LEFT, anchor=W)
24468  #
24469  awg2model = Frame( frame2r )
24470  awg2model.pack(side=TOP,fill=X) #)
24471  AWGBModeLabel = Label(awg2model, text="AWG B Mode", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24472  AWGBModeLabel.pack(side=LEFT, fill=X)
24473  AWGBShapeLabel = Label(awg2model, text="AWG B Shape", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24474  AWGBShapeLabel.pack(side=LEFT, fill=X)
24475  #
24476  awg2ampl = Frame( frame2r )
24477  awg2ampl.pack(side=TOP)
24478  amp2lab = Label(awg2ampl) #, text="Min Ch B")
24479  amp2lab.grid(row=0,column=0,sticky=E+S+N+W)
24480  #amp2lab.pack(side=LEFT, anchor=W)
24481  off2lab = Label(awg2ampl) #, text="Max Ch B")
24482  off2lab.grid(row=0,column=1,sticky=E+S+N+W)
24483  #off2lab.pack(side=LEFT, anchor=W)
24484  freq2lab = Label(awg2ampl, text="Freq")
24485  freq2lab.grid(row=0,column=2,sticky=E+S+N+W)
24486  # freq2lab.pack(side=LEFT, anchor=W)
24487  #
24488  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24489  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
24490  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
24491  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24492  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
24493  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
24494  AWGBAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24495  AWGBAmplEntry.delete(0,"end")
24496  AWGBAmplEntry.insert(0,0.0)
24497  #
24498  AWGBOffsetEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24499  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
24500  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
24501  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24502  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
24503  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
24504  AWGBOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24505  AWGBOffsetEntry.delete(0,"end")
24506  AWGBOffsetEntry.insert(0,0.0)
24507 
24508  if AWG_Amp_Mode.get() == 0:
24509  amp2lab.config(text = "Min" ) # change displayed value
24510  off2lab.config(text = "Max" ) # change displayed value
24511  else:
24512  amp2lab.config(text = "Amp" )
24513  off2lab.config(text = "Off" )
24514  # AWG Frequency
24515  AWGBFreqEntry = Entry(awg2ampl, width=7, cursor='double_arrow')
24516  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
24517  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
24518  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24519  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
24520  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
24521  AWGBFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24522  AWGBFreqEntry.delete(0,"end")
24523  AWGBFreqEntry.insert(0,100.0)
24524  # AWG Phase or delay select sub frame
24525  # AWG Phase sub frame
24526  awg2phase = Frame( frame2r )
24527  awg2phase.pack(side=TOP)
24528  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
24529  awgbph.pack(side=LEFT, anchor=W)
24530  AWGBPhaseEntry = Entry(awg2phase, width=5, cursor='double_arrow')
24531  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
24532  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
24533  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24534  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
24535  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
24536  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
24537  AWGBPhaseEntry.delete(0,"end")
24538  AWGBPhaseEntry.insert(0,0)
24539  phaseblab = Label(awg2phase, text="Deg")
24540  phaseblab.pack(side=LEFT, anchor=W)
24541  # AWG duty cycle frame
24542  awg2dc = Frame( frame2r )
24543  awg2dc.pack(side=TOP)
24544  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
24545  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24546  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
24547  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24548  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
24549  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
24550  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
24551  AWGBDutyCycleEntry.delete(0,"end")
24552  AWGBDutyCycleEntry.insert(0,50)
24553  duty2lab = Label(awg2dc, text="%")
24554  duty2lab.pack(side=LEFT, anchor=W)
24555  #
24556  bcompa = Checkbutton(frame2r, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)
24557  bcompa.pack(side=TOP)
24558 
24559  awgsync = Checkbutton(frame2r, text="Sync AWG", variable=AWGSync, command=BAWGSync)
24560  awgsync.pack(side=TOP)
24561  if ShowBallonHelp > 0:
24562  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
24563  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
24564  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
24565  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
24566  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
24567  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
24568  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
24569  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
24570 
24571 # input probe wigets
24572 prlab = Label(frame2r, text="Adjust Gain / Offset")
24573 prlab.pack(side=TOP)
24574 # Input Probes sub frame
24575 ProbeA = Frame( frame2r )
24576 ProbeA.pack(side=TOP)
24577 gain1lab = Button(ProbeA, text="CA-V", width=4, style="Ctrace1.TButton", command=ReSetAGO)
24578 gain1lab.pack(side=LEFT,fill=X)
24579 CHAVGainEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24580 CHAVGainEntry.bind('<Return>', onTextKey)
24581 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
24582 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24583 CHAVGainEntry.bind("<Button-5>", onTextScroll)
24584 CHAVGainEntry.bind('<Key>', onTextKey)
24585 CHAVGainEntry.pack(side=LEFT)
24586 CHAVGainEntry.delete(0,"end")
24587 CHAVGainEntry.insert(0,1.0)
24588 CHAVOffsetEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24589 CHAVOffsetEntry.bind('<Return>', onTextKey)
24590 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24591 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24592 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
24593 CHAVOffsetEntry.bind('<Key>', onTextKey)
24594 CHAVOffsetEntry.pack(side=LEFT)
24595 CHAVOffsetEntry.delete(0,"end")
24596 CHAVOffsetEntry.insert(0,0.0)
24597 #
24598 ProbeB = Frame( frame2r )
24599 ProbeB.pack(side=TOP)
24600 gain2lab = Button(ProbeB, text="CB-V", width=4, style="Ctrace2.TButton", command=ReSetBGO)
24601 gain2lab.pack(side=LEFT,fill=X)
24602 CHBVGainEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24603 CHBVGainEntry.bind('<Return>', onTextKey)
24604 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
24605 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24606 CHBVGainEntry.bind("<Button-5>", onTextScroll)
24607 CHBVGainEntry.bind('<Key>', onTextKey)
24608 CHBVGainEntry.pack(side=LEFT)
24609 CHBVGainEntry.delete(0,"end")
24610 CHBVGainEntry.insert(0,1.0)
24611 CHBVOffsetEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24612 CHBVOffsetEntry.bind('<Return>', onTextKey)
24613 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24614 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24615 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
24616 CHBVOffsetEntry.bind('<Key>', onTextKey)
24617 CHBVOffsetEntry.pack(side=LEFT)
24618 CHBVOffsetEntry.delete(0,"end")
24619 CHBVOffsetEntry.insert(0,0.0)
24620 #
24621 ProbeAI = Frame( frame2r )
24622 ProbeAI.pack(side=TOP)
24623 gainailab = Button(ProbeAI, text="CA-I", width=4, style="Ctrace3.TButton", command=ReSetAIGO)
24624 gainailab.pack(side=LEFT,fill=X)
24625 CHAIGainEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24626 CHAIGainEntry.bind('<Return>', onTextKey)
24627 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
24628 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24629 CHAIGainEntry.bind("<Button-5>", onTextScroll)
24630 CHAIGainEntry.bind('<Key>', onTextKey)
24631 CHAIGainEntry.pack(side=LEFT)
24632 CHAIGainEntry.delete(0,"end")
24633 CHAIGainEntry.insert(0,1.0)
24634 CHAIOffsetEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24635 CHAIOffsetEntry.bind('<Return>', onTextKey)
24636 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24637 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24638 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
24639 CHAIOffsetEntry.bind('<Key>', onTextKey)
24640 CHAIOffsetEntry.pack(side=LEFT)
24641 CHAIOffsetEntry.delete(0,"end")
24642 CHAIOffsetEntry.insert(0,0.0)
24643 #
24644 ProbeBI = Frame( frame2r )
24645 ProbeBI.pack(side=TOP)
24646 gainbilab = Button(ProbeBI, text="CB-I", width=4, style="Ctrace4.TButton", command=ReSetBIGO)
24647 gainbilab.pack(side=LEFT,fill=X)
24648 CHBIGainEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24649 CHBIGainEntry.bind('<Return>', onTextKey)
24650 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
24651 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24652 CHBIGainEntry.bind("<Button-5>", onTextScroll)
24653 CHBIGainEntry.bind('<Key>', onTextKey)
24654 CHBIGainEntry.pack(side=LEFT)
24655 CHBIGainEntry.delete(0,"end")
24656 CHBIGainEntry.insert(0,1.0)
24657 CHBIOffsetEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24658 CHBIOffsetEntry.bind('<Return>', onTextKey)
24659 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24660 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24661 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
24662 CHBIOffsetEntry.bind('<Key>', onTextKey)
24663 CHBIOffsetEntry.pack(side=LEFT)
24664 CHBIOffsetEntry.delete(0,"end")
24665 CHBIOffsetEntry.insert(0,0.0)
24666 # Add a pair of user entry wigets
24667 if EnableUserEntries > 0:
24668  UserEnt = Frame( frame2r )
24669  UserEnt.pack(side=TOP)
24670  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
24671  userentlab.pack(side=LEFT,fill=X)
24672  User1Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24673  User1Entry.bind('<Return>', onTextKey)
24674  User1Entry.bind('<MouseWheel>', onTextScroll)
24675  User1Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24676  User1Entry.bind("<Button-5>", onTextScroll)
24677  User1Entry.bind('<Key>', onTextKey)
24678  User1Entry.pack(side=LEFT)
24679  User1Entry.delete(0,"end")
24680  User1Entry.insert(0,0.0)
24681  User2Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24682  User2Entry.bind('<Return>', onTextKey)
24683  User2Entry.bind('<MouseWheel>', onTextScroll)
24684  User2Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24685  User2Entry.bind("<Button-5>", onTextScroll)
24686  User2Entry.bind('<Key>', onTextKey)
24687  User2Entry.pack(side=LEFT)
24688  User2Entry.delete(0,"end")
24689  User2Entry.insert(0,0.0)
24690 # add ADI logo Don't mess with this bit map data!
24691 ADIlogo = """
24692 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
24693 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
24694 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
24695 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
24696 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
24697 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
24698 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
24699 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
24700 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
24701 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
24702 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
24703 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
24704 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
24705 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
24706 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
24707 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
24708 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
24709 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
24710 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
24711 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
24712 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
24713 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
24714 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
24715 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
24716 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
24717 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
24718 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
24719 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
24720 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
24721 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
24722 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
24723 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
24724 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
24725 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
24726 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
24727 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
24728 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
24729 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
24730 """
24731 logo = PhotoImage(data=ADIlogo)
24732 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
24733 ADI1.pack(side=TOP)
24734 
24735 # Bottom Buttons
24736 # Voltage channel A
24737 if ButtonOrder == 1:
24738  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24739  CHAlab.pack(side=LEFT)
24740 CHAsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHvpdiv, command=BCHAlevel)
24741 #CHAsb = ttk.Spinbox(frame3, cursor='double_arrow', style="Div.TSpinbox", values=CHvpdiv, command=BCHAlevel)
24742 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
24743 CHAsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24744 CHAsb.bind("<Button-5>", onSpinBoxScroll)
24745 CHAsb.pack(side=LEFT)
24746 CHAsb.delete(0,"end")
24747 CHAsb.insert(0,0.5)
24748 #
24749 if ButtonOrder == 0:
24750  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24751  CHAlab.pack(side=LEFT)
24752 #
24753 if ButtonOrder == 1:
24754  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24755  CHAofflab.pack(side=LEFT)
24756 CHAVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24757 CHAVPosEntry.bind("<Return>", BOffsetA)
24758 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24759 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24760 CHAVPosEntry.bind("<Button-5>", onTextScroll)
24761 CHAVPosEntry.bind('<Key>', onTextKey)
24762 CHAVPosEntry.pack(side=LEFT)
24763 CHAVPosEntry.delete(0,"end")
24764 CHAVPosEntry.insert(0,2.5)
24765 if ButtonOrder == 0:
24766  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24767  CHAofflab.pack(side=LEFT)
24768 # Current channel A
24769 if ButtonOrder == 1:
24770  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24771  CHAIlab.pack(side=LEFT)
24772 CHAIsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHipdiv, command=BCHAIlevel)
24773 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
24774 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24775 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24776 CHAIsb.pack(side=LEFT)
24777 CHAIsb.delete(0,"end")
24778 CHAIsb.insert(0,50.0)
24779 if ButtonOrder == 0:
24780  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24781  CHAIlab.pack(side=LEFT)
24782 #
24783 if ButtonOrder == 1:
24784  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24785  CHAIofflab.pack(side=LEFT)
24786 CHAIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24787 CHAIPosEntry.bind("<Return>", BIOffsetA)
24788 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24789 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24790 CHAIPosEntry.bind("<Button-5>", onTextScroll)
24791 CHAIPosEntry.bind('<Key>', onTextKey)
24792 CHAIPosEntry.pack(side=LEFT)
24793 CHAIPosEntry.delete(0,"end")
24794 CHAIPosEntry.insert(0,0.0)
24795 if ButtonOrder == 0:
24796  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24797  CHAIofflab.pack(side=LEFT)
24798 # Voltage channel B
24799 if ButtonOrder == 1:
24800  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24801  CHBlab.pack(side=LEFT)
24802 CHBsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHvpdiv, command=BCHBlevel)
24803 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
24804 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24805 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24806 CHBsb.pack(side=LEFT)
24807 CHBsb.delete(0,"end")
24808 CHBsb.insert(0,0.5)
24809 #
24810 if ButtonOrder == 0:
24811  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24812  CHBlab.pack(side=LEFT)
24813 #
24814 if ButtonOrder == 1:
24815  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24816  CHBofflab.pack(side=LEFT)
24817 CHBVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24818 CHBVPosEntry.bind("<Return>", BOffsetB)
24819 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24820 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24821 CHBVPosEntry.bind("<Button-5>", onTextScroll)
24822 CHBVPosEntry.bind('<Key>', onTextKey)
24823 CHBVPosEntry.pack(side=LEFT)
24824 CHBVPosEntry.delete(0,"end")
24825 CHBVPosEntry.insert(0,2.5)
24826 if ButtonOrder == 0:
24827  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24828  CHBofflab.pack(side=LEFT)
24829 # Current channel B
24830 if ButtonOrder == 1:
24831  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24832  CHBIlab.pack(side=LEFT)
24833 CHBIsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHipdiv, command=BCHBIlevel)
24834 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
24835 CHBIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24836 CHBIsb.bind("<Button-5>", onSpinBoxScroll)
24837 CHBIsb.pack(side=LEFT)
24838 CHBIsb.delete(0,"end")
24839 CHBIsb.insert(0,50.0)
24840 if ButtonOrder == 0:
24841  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24842  CHBIlab.pack(side=LEFT)
24843 #
24844 if ButtonOrder == 1:
24845  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24846  CHBIofflab.pack(side=LEFT)
24847 CHBIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24848 CHBIPosEntry.bind("<Return>", BIOffsetB)
24849 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24850 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24851 CHBIPosEntry.bind("<Button-5>", onTextScroll)
24852 CHBIPosEntry.bind('<Key>', onTextKey)
24853 CHBIPosEntry.pack(side=LEFT)
24854 CHBIPosEntry.delete(0,"end")
24855 CHBIPosEntry.insert(0,0.0)
24856 if ButtonOrder == 0:
24857  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24858  CHBIofflab.pack(side=LEFT)
24859 #
24860 if ShowBallonHelp > 0:
24861  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
24862  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
24863  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
24864  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
24865  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
24866  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
24867  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
24868  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
24869  gain1lab_tip = CreateToolTip(gain1lab, 'Reset Gain to 1.0 and Offset to 0.0')
24870  gain2lab_tip = CreateToolTip(gain2lab, 'Reset Gain to 1.0 and Offset to 0.0')
24871  gainailab_tip = CreateToolTip(gainailab, 'Reset Gain to 1.0 and Offset to 0.0')
24872  gainbilab_tip = CreateToolTip(gainbilab, 'Reset Gain to 1.0 and Offset to 0.0')
24873 #
24874 root.geometry('+300+0')
24875 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
24876 #===== Initalize device ======
24877 if not numpy_found:
24878  root.update()
24879  showwarning("WARNING","Numpy not found!")
24880  root.destroy()
24881  exit()
24882 #
24883 BrdSel = IntVar(0)
24884 BoardStatus = IntVar(0)
24885 if pysmu_found:
24886  ConnectDevice()
24887  #session.hotplug_attach(ConnectDevice)
24888  #session.hotplug_detach(ConnectDevice)
24889  if EnableScopeOnly == 0:
24890  MakeAWGWindow() # build AWG window
24891  else:
24892  AWGScreenStatus.set(1)
24893  # root.update()
24894  BLoadConfig("alice-last-config.cfg") # load configuration from last session
24895  if LocalLanguage != "English":
24896  BLoadConfig(LocalLanguage) # load local language configuration
24897 # ================ Call main routine ===============================
24898  root.update() # Activate updated screens
24899 # Start sampling
24900  Analog_In()
24901 else:
24902  root.update()
24903  showwarning("WARNING","Pysmu not found!")
24904  root.destroy()
24905  exit()
24906 
alice-desktop-1.Analog_Chop_Time
def Analog_Chop_Time()
Definition: alice-desktop-1.3-linux-test.pyw:4121
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19733
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2697
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2731
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2637
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16112
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18940
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16139
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18744
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22081
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3-linux-test.pyw:1913
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3-linux-test.pyw:2813
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21837
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22275
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19042
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3-linux-test.pyw:3125
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3-linux-test.pyw:13191
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:9669
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6002
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3-linux-test.pyw:1557
alice-desktop-1.onAWGFiltBScroll
def onAWGFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21656
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3-linux-test.pyw:17168
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3-linux-test.pyw:3105
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3-linux-test.pyw:22117
alice-desktop-1.RunScript
def RunScript()
Run a script file.
Definition: alice-desktop-1.3-linux-test.pyw:1920
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3-linux-test.pyw:5648
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3-linux-test.pyw:11359
alice-desktop-1.Analog_Roll_time
def Analog_Roll_time()
Definition: alice-desktop-1.3-linux-test.pyw:3986
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:20773
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3-linux-test.pyw:2867
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14738
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:11882
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3-linux-test.pyw:12766
alice-desktop-1.ToggleAWGBPhaseDelay
def ToggleAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11682
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3-linux-test.pyw:23134
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3-linux-test.pyw:22281
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:12020
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3-linux-test.pyw:7101
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:9679
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2711
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3-linux-test.pyw:14742
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3-linux-test.pyw:21847
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3-linux-test.pyw:17084
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12310
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:11775
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22688
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9721
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2975
alice-desktop-1.Sine_Phase
def Sine_Phase()
Definition: alice-desktop-1.3-linux-test.pyw:4937
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3-linux-test.pyw:14724
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22706
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11246
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3300
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14786
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3-linux-test.pyw:13212
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3-linux-test.pyw:13107
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:9713
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
Definition: alice-desktop-1.3-linux-test.pyw:4192
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3-linux-test.pyw:12847
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3-linux-test.pyw:3312
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21589
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17749
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2475
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3-linux-test.pyw:20032
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3-linux-test.pyw:15866
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3-linux-test.pyw:15847
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3-linux-test.pyw:12918
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3-linux-test.pyw:2754
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9090
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22716
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3232
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10579
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15902
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2088
alice-desktop-1.AddAWGANoise
def AddAWGANoise()
Definition: alice-desktop-1.3-linux-test.pyw:11492
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15330
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9768
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3-linux-test.pyw:13447
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18195
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3-linux-test.pyw:21843
alice-desktop-1.AWGALoadCSV
def AWGALoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:10354
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17803
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2981
alice-desktop-1.AddAWGBNoise
def AddAWGBNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12729
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3-linux-test.pyw:1569
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15578
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3-linux-test.pyw:20995
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18043
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:11336
alice-desktop-1.BrownNoise
def BrownNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10031
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:16345
alice-desktop-1.BLoadDFiltAClip
def BLoadDFiltAClip()
Definition: alice-desktop-1.3-linux-test.pyw:2203
alice-desktop-1.BSnapShotXY
def BSnapShotXY()
Take snap shot of displayed XY Traces.
Definition: alice-desktop-1.3-linux-test.pyw:2318
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:12116
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15526
alice-desktop-1.BReadFromClipboard
def BReadFromClipboard()
Definition: alice-desktop-1.3-linux-test.pyw:2193
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3-linux-test.pyw:18715
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3-linux-test.pyw:23331
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13800
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18264
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3-linux-test.pyw:10862
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18004
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10428
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:9653
alice-desktop-1.DestroyOOTwindow
def DestroyOOTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:23500
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15861
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:10988
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3-linux-test.pyw:21143
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:17971
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:10804
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22581
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:19052
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9746
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3-linux-test.pyw:12240
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2849
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2704
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3-linux-test.pyw:2921
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:10414
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3-linux-test.pyw:17981
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9284
alice-desktop-1.onRetAWGFiltB
def onRetAWGFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21653
alice-desktop-1.ToggleAWGAPhaseDelay
def ToggleAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10256
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18188
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3-linux-test.pyw:893
alice-desktop-1.BAWGFiltBMath
def BAWGFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21744
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:17928
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15722
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21063
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3-linux-test.pyw:5512
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:9694
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3-linux-test.pyw:12840
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10278
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:11694
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:5997
alice-desktop-1.AWGALoadWAV
def AWGALoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:10437
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2105
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3331
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3-linux-test.pyw:3005
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3-linux-test.pyw:2630
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3288
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22362
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3-linux-test.pyw:1580
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3-linux-test.pyw:18181
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3-linux-test.pyw:1575
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16135
alice-desktop-1.BLoadAWGFiltA
def BLoadAWGFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21679
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21502
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:9645
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3-linux-test.pyw:2262
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2963
font
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12494
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3-linux-test.pyw:1768
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:12439
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3-linux-test.pyw:23100
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15910
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3-linux-test.pyw:22589
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9066
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11841
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3-linux-test.pyw:17636
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11722
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10183
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4980
alice-desktop-1.time_points_from_freq
def time_points_from_freq(freq, fs=1, density=False)
Definition: alice-desktop-1.3-linux-test.pyw:9949
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital RC filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3-linux-test.pyw:4959
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21926
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9104
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3-linux-test.pyw:17967
alice-desktop-1.BLoadDFiltBClip
def BLoadDFiltBClip()
Definition: alice-desktop-1.3-linux-test.pyw:2209
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:18166
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5871
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3-linux-test.pyw:11741
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3-linux-test.pyw:21612
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15918
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3-linux-test.pyw:887
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3-linux-test.pyw:3087
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22207
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3-linux-test.pyw:2228
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3-linux-test.pyw:21223
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21498
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3-linux-test.pyw:2945
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3-linux-test.pyw:12756
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:17975
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2734
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3-linux-test.pyw:21520
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3-linux-test.pyw:20919
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3-linux-test.pyw:15595
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3378
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2987
alice-desktop-1.SchroederPhase
def SchroederPhase(Length, NrTones, Ampl)
Definition: alice-desktop-1.3-linux-test.pyw:10063
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3-linux-test.pyw:13377
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2287
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11059
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3-linux-test.pyw:5832
alice-desktop-1.fit_exp
def fit_exp(xs, ys)
Definition: alice-desktop-1.3-linux-test.pyw:21792
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:18124
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10090
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3-linux-test.pyw:885
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3-linux-test.pyw:15534
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3-linux-test.pyw:20818
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3-linux-test.pyw:18999
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3-linux-test.pyw:10481
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3-linux-test.pyw:2760
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:18173
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:17921
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3-linux-test.pyw:2801
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3-linux-test.pyw:2744
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15880
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19421
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3-linux-test.pyw:12579
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5752
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3-linux-test.pyw:11519
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:18185
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9242
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3-linux-test.pyw:1563
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3-linux-test.pyw:12602
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2897
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3-linux-test.pyw:20043
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15679
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3-linux-test.pyw:18131
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:10475
alice-desktop-1.onRetAWGFiltA
def onRetAWGFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21627
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17990
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21527
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:18152
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:9661
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:12175
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3-linux-test.pyw:892
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21959
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3-linux-test.pyw:12877
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3254
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18327
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:9674
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3-linux-test.pyw:13386
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11704
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21574
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22268
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3-linux-test.pyw:16144
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:18202
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3-linux-test.pyw:13064
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3-linux-test.pyw:12883
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10221
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:18177
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22026
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3-linux-test.pyw:13152
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13368
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1901
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3-linux-test.pyw:17942
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3-linux-test.pyw:940
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:14153
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3-linux-test.pyw:20767
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3-linux-test.pyw:18159
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3-linux-test.pyw:22511
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18258
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3-linux-test.pyw:8272
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3-linux-test.pyw:9689
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21523
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3-linux-test.pyw:3415
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:16121
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3-linux-test.pyw:19032
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2338
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:12372
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13438
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3-linux-test.pyw:9367
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:3700
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3-linux-test.pyw:22470
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3-linux-test.pyw:20687
alice-desktop-1.ReSetAGO
def ReSetAGO()
Definition: alice-desktop-1.3-linux-test.pyw:23345
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15856
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3-linux-test.pyw:20603
alice-desktop-1.IACapReset
def IACapReset()
Definition: alice-desktop-1.3-linux-test.pyw:15547
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3-linux-test.pyw:5312
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3-linux-test.pyw:5970
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3-linux-test.pyw:20954
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3-linux-test.pyw:17028
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3338
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:21916
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:9737
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2657
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:20780
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:14398
alice-desktop-1.BLoadAWGFiltB
def BLoadAWGFiltB()
Definition: alice-desktop-1.3-linux-test.pyw:21720
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3-linux-test.pyw:9709
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:906
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5838
alice-desktop-1.AWGBLoadWAV
def AWGBLoadWAV()
Definition: alice-desktop-1.3-linux-test.pyw:11850
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2969
alice-desktop-1.OpenOtherTools
def OpenOtherTools()
Definition: alice-desktop-1.3-linux-test.pyw:23377
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:12537
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18023
alice-desktop-1.BSaveMuxData
def BSaveMuxData()
Save External Mux data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2118
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3-linux-test.pyw:17949
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22342
alice-desktop-1.IACapZero
def IACapZero()
Definition: alice-desktop-1.3-linux-test.pyw:15540
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15886
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:11916
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3-linux-test.pyw:10922
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13359
alice-desktop-1.ReSetBIGO
def ReSetBIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23369
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:22738
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3-linux-test.pyw:13458
alice-desktop-1.ReSetBGO
def ReSetBGO()
Definition: alice-desktop-1.3-linux-test.pyw:23353
alice-desktop-1.BlueNoise
def BlueNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10015
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2891
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3-linux-test.pyw:5000
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3-linux-test.pyw:16130
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3-linux-test.pyw:18138
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15585
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3-linux-test.pyw:13222
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3-linux-test.pyw:20510
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3-linux-test.pyw:18337
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:10394
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11647
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:18145
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3-linux-test.pyw:5992
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15712
alice-desktop-1.CreateToolTip.configure
def configure(self, text)
Re Configure text string.
Definition: alice-desktop-1.3-linux-test.pyw:934
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3-linux-test.pyw:895
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3-linux-test.pyw:3769
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11609
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:2827
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3-linux-test.pyw:5353
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3-linux-test.pyw:22285
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:17963
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13462
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3-linux-test.pyw:13465
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3-linux-test.pyw:9113
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3-linux-test.pyw:884
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3-linux-test.pyw:12790
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5937
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3365
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3-linux-test.pyw:2885
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:15320
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3-linux-test.pyw:10076
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3-linux-test.pyw:2909
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19097
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3-linux-test.pyw:2132
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3-linux-test.pyw:13416
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3-linux-test.pyw:21217
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19401
alice-desktop-1.TimeSeriesSingleTone
def TimeSeriesSingleTone(n, BinNum, Fsample, mag)
Definition: alice-desktop-1.3-linux-test.pyw:9989
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10143
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3-linux-test.pyw:6007
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3-linux-test.pyw:12867
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3-linux-test.pyw:23140
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3-linux-test.pyw:14734
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3-linux-test.pyw:18737
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3-linux-test.pyw:888
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19742
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3-linux-test.pyw:15875
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3-linux-test.pyw:10268
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3-linux-test.pyw:22696
alice-desktop-1.BLoadAWGBFiltClip
def BLoadAWGBFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2221
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3-linux-test.pyw:12857
alice-desktop-1.PinkNoise
def PinkNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10000
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21545
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:9637
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3-linux-test.pyw:13134
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3-linux-test.pyw:6022
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3-linux-test.pyw:886
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3-linux-test.pyw:11190
alice-desktop-1.BRoll
def BRoll()
Toggel on/off Roll Sweep Mode.
Definition: alice-desktop-1.3-linux-test.pyw:3188
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3-linux-test.pyw:11821
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2999
messagebox
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3-linux-test.pyw:13143
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3391
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21213
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3-linux-test.pyw:5014
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3-linux-test.pyw:21322
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3-linux-test.pyw:12061
alice-desktop-1.SetChopMuxMode
def SetChopMuxMode()
Definition: alice-desktop-1.3-linux-test.pyw:18970
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3-linux-test.pyw:21551
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3-linux-test.pyw:5523
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9200
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3-linux-test.pyw:898
alice-desktop-1.TimeSeriesNoise
def TimeSeriesNoise(n, Fsample, mag, b=4)
Definition: alice-desktop-1.3-linux-test.pyw:9967
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3-linux-test.pyw:9326
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3-linux-test.pyw:15553
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3-linux-test.pyw:21495
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3-linux-test.pyw:9054
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3-linux-test.pyw:5361
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3-linux-test.pyw:22032
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10653
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3-linux-test.pyw:10727
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3-linux-test.pyw:20625
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3-linux-test.pyw:19007
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:17997
alice-desktop-1.BuildAWGBoxCarA
def BuildAWGBoxCarA()
Definition: alice-desktop-1.3-linux-test.pyw:21634
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3-linux-test.pyw:11556
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2993
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3-linux-test.pyw:21069
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:18275
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3-linux-test.pyw:12830
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3-linux-test.pyw:2718
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3-linux-test.pyw:15927
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3-linux-test.pyw:9699
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3-linux-test.pyw:1907
alice-desktop-1.AWGBLoadCSV
def AWGBLoadCSV()
Definition: alice-desktop-1.3-linux-test.pyw:11783
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18217
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3-linux-test.pyw:22430
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3-linux-test.pyw:9704
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3-linux-test.pyw:17652
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3404
alice-desktop-1.onAWGFiltAScroll
def onAWGFiltAScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:21630
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3-linux-test.pyw:11291
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3-linux-test.pyw:14913
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18225
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3-linux-test.pyw:10768
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3-linux-test.pyw:10346
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2052
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3-linux-test.pyw:13442
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3-linux-test.pyw:10296
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21809
alice-desktop-1.BSaveToClipBoard
def BSaveToClipBoard(TempBuffer)
Definition: alice-desktop-1.3-linux-test.pyw:2184
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3-linux-test.pyw:2267
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3-linux-test.pyw:5642
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3265
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3-linux-test.pyw:17741
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3-linux-test.pyw:10107
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3-linux-test.pyw:2933
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2903
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2033
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3-linux-test.pyw:3324
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3-linux-test.pyw:3174
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3-linux-test.pyw:912
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3-linux-test.pyw:13395
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3-linux-test.pyw:3351
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3-linux-test.pyw:19758
alice-desktop-1.AWGBConfigMath
def AWGBConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:11904
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3-linux-test.pyw:1895
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3-linux-test.pyw:2464
alice-desktop-1.ReSetAIGO
def ReSetAIGO()
Definition: alice-desktop-1.3-linux-test.pyw:23361
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3-linux-test.pyw:12813
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3-linux-test.pyw:12833
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3-linux-test.pyw:2728
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3-linux-test.pyw:22826
alice-desktop-1.BuildAWGBoxCarB
def BuildAWGBoxCarB()
Definition: alice-desktop-1.3-linux-test.pyw:21660
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3-linux-test.pyw:9729
alice-desktop-1.VioletNoise
def VioletNoise(N, mag)
Definition: alice-desktop-1.3-linux-test.pyw:10047
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3-linux-test.pyw:2677
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3-linux-test.pyw:17956
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3-linux-test.pyw:7377
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3-linux-test.pyw:13337
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22822
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3-linux-test.pyw:17984
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3-linux-test.pyw:13037
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3-linux-test.pyw:6012
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3-linux-test.pyw:13405
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3-linux-test.pyw:13423
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3-linux-test.pyw:3031
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3-linux-test.pyw:2957
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3-linux-test.pyw:5904
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3-linux-test.pyw:23324
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19023
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:18209
alice-desktop-1.BuildRejectFilter
def BuildRejectFilter(Order, Freject, Fsample)
Definition: alice-desktop-1.3-linux-test.pyw:21761
alice-desktop-1.AWGAConfigMath
def AWGAConfigMath()
Definition: alice-desktop-1.3-linux-test.pyw:10503
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3-linux-test.pyw:19411
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3-linux-test.pyw:3578
ttk
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:11951
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3-linux-test.pyw:2838
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3-linux-test.pyw:23337
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3-linux-test.pyw:882
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3-linux-test.pyw:21012
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3-linux-test.pyw:13170
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3-linux-test.pyw:2410
alice-desktop-1.Cal_trace_scalars
def Cal_trace_scalars(SampleStart, SampleEnd)
Definition: alice-desktop-1.3-linux-test.pyw:4909
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3-linux-test.pyw:9097
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3-linux-test.pyw:15894
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3-linux-test.pyw:10315
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3-linux-test.pyw:22087
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3-linux-test.pyw:21315
alice-desktop-1.BLoadAWGAFiltClip
def BLoadAWGAFiltClip()
Definition: alice-desktop-1.3-linux-test.pyw:2215
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3-linux-test.pyw:12769
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3-linux-test.pyw:20862
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3-linux-test.pyw:902
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3-linux-test.pyw:18270
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3-linux-test.pyw:13233
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22322
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3-linux-test.pyw:12963
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3-linux-test.pyw:9042
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3-linux-test.pyw:2071
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3-linux-test.pyw:17935
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3-linux-test.pyw:22830
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2429
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3-linux-test.pyw:6017
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:18011
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3-linux-test.pyw:20655
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3-linux-test.pyw:9158
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3-linux-test.pyw:11876
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3-linux-test.pyw:16992
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3-linux-test.pyw:13430
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3-linux-test.pyw:2446
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3-linux-test.pyw:13161
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3-linux-test.pyw:3276
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3-linux-test.pyw:15705
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3-linux-test.pyw:3199
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3-linux-test.pyw:17987
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3-linux-test.pyw:10515
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3-linux-test.pyw:17978
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3-linux-test.pyw:3243
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:17783
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3-linux-test.pyw:928
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3-linux-test.pyw:3141
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3-linux-test.pyw:20913
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3-linux-test.pyw:9684
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3-linux-test.pyw:17772
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3-linux-test.pyw:17914
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3-linux-test.pyw:11570
alice-desktop-1.BAWGFiltAMath
def BAWGFiltAMath()
Definition: alice-desktop-1.3-linux-test.pyw:21703
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3-linux-test.pyw:9078
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3-linux-test.pyw:11122
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3-linux-test.pyw:1998
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3-linux-test.pyw:22710